util/Error: new error passing library
Replaces GLib's GError.
This commit is contained in:
@@ -17,17 +17,22 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
const Domain audio_format_domain("audio_format");
|
||||
|
||||
bool
|
||||
audio_check_sample_rate(unsigned long sample_rate, GError **error_r)
|
||||
audio_check_sample_rate(unsigned long sample_rate, Error &error)
|
||||
{
|
||||
if (!audio_valid_sample_rate(sample_rate)) {
|
||||
g_set_error(error_r, audio_format_quark(), 0,
|
||||
"Invalid sample rate: %lu", sample_rate);
|
||||
error.Format(audio_format_domain,
|
||||
"Invalid sample rate: %lu", sample_rate);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -35,12 +40,12 @@ audio_check_sample_rate(unsigned long sample_rate, GError **error_r)
|
||||
}
|
||||
|
||||
bool
|
||||
audio_check_sample_format(SampleFormat sample_format, GError **error_r)
|
||||
audio_check_sample_format(SampleFormat sample_format, Error &error)
|
||||
{
|
||||
if (!audio_valid_sample_format(sample_format)) {
|
||||
g_set_error(error_r, audio_format_quark(), 0,
|
||||
"Invalid sample format: %u",
|
||||
unsigned(sample_format));
|
||||
error.Format(audio_format_domain,
|
||||
"Invalid sample format: %u",
|
||||
unsigned(sample_format));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,11 +53,11 @@ audio_check_sample_format(SampleFormat sample_format, GError **error_r)
|
||||
}
|
||||
|
||||
bool
|
||||
audio_check_channel_count(unsigned channels, GError **error_r)
|
||||
audio_check_channel_count(unsigned channels, Error &error)
|
||||
{
|
||||
if (!audio_valid_channel_count(channels)) {
|
||||
g_set_error(error_r, audio_format_quark(), 0,
|
||||
"Invalid channel count: %u", channels);
|
||||
error.Format(audio_format_domain,
|
||||
"Invalid channel count: %u", channels);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,11 +67,11 @@ audio_check_channel_count(unsigned channels, GError **error_r)
|
||||
bool
|
||||
audio_format_init_checked(AudioFormat &af, unsigned long sample_rate,
|
||||
SampleFormat sample_format, unsigned channels,
|
||||
GError **error_r)
|
||||
Error &error)
|
||||
{
|
||||
if (audio_check_sample_rate(sample_rate, error_r) &&
|
||||
audio_check_sample_format(sample_format, error_r) &&
|
||||
audio_check_channel_count(channels, error_r)) {
|
||||
if (audio_check_sample_rate(sample_rate, error) &&
|
||||
audio_check_sample_format(sample_format, error) &&
|
||||
audio_check_channel_count(channels, error)) {
|
||||
af = AudioFormat(sample_rate, sample_format, channels);
|
||||
assert(af.IsValid());
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user