diff options
author | Max Kellermann <max@duempel.org> | 2013-08-10 18:02:44 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-09-04 18:14:22 +0200 |
commit | 29030b54c98b0aee65fbc10ebf7ba36bed98c02c (patch) | |
tree | 79766830b55ebca38ddbce84d8d548227eedb69e /src/CheckAudioFormat.cxx | |
parent | c9fcc7f14860777458153eb2d13c773ccfa1daa2 (diff) | |
download | mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.gz mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.xz mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.zip |
util/Error: new error passing library
Replaces GLib's GError.
Diffstat (limited to 'src/CheckAudioFormat.cxx')
-rw-r--r-- | src/CheckAudioFormat.cxx | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/CheckAudioFormat.cxx b/src/CheckAudioFormat.cxx index fabffd56c..1f3ef4925 100644 --- a/src/CheckAudioFormat.cxx +++ b/src/CheckAudioFormat.cxx @@ -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; |