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/DecoderAPI.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/DecoderAPI.cxx')
-rw-r--r-- | src/DecoderAPI.cxx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/DecoderAPI.cxx b/src/DecoderAPI.cxx index 7286bb52f..d364a3aaa 100644 --- a/src/DecoderAPI.cxx +++ b/src/DecoderAPI.cxx @@ -28,6 +28,7 @@ #include "DecoderInternal.hxx" #include "Song.hxx" #include "InputStream.hxx" +#include "util/Error.hxx" #include <glib.h> @@ -257,8 +258,6 @@ size_t decoder_read(struct decoder *decoder, void *buffer, size_t length) { /* XXX don't allow decoder==NULL */ - GError *error = NULL; - size_t nbytes; assert(decoder == NULL || decoder->dc->state == DECODE_STATE_START || @@ -283,14 +282,13 @@ size_t decoder_read(struct decoder *decoder, is->cond.wait(is->mutex); } - nbytes = input_stream_read(is, buffer, length, &error); - assert(nbytes == 0 || error == NULL); - assert(nbytes > 0 || error != NULL || input_stream_eof(is)); + Error error; + size_t nbytes = input_stream_read(is, buffer, length, error); + assert(nbytes == 0 || !error.IsDefined()); + assert(nbytes > 0 || error.IsDefined() || input_stream_eof(is)); - if (gcc_unlikely(nbytes == 0 && error != nullptr)) { - g_warning("%s", error->message); - g_error_free(error); - } + if (gcc_unlikely(nbytes == 0 && error.IsDefined())) + g_warning("%s", error.GetMessage()); input_stream_unlock(is); @@ -364,7 +362,6 @@ decoder_data(struct decoder *decoder, uint16_t kbit_rate) { struct decoder_control *dc = decoder->dc; - GError *error = NULL; enum decoder_command cmd; assert(dc->state == DECODE_STATE_DECODE); @@ -397,16 +394,17 @@ decoder_data(struct decoder *decoder, } if (dc->in_audio_format != dc->out_audio_format) { + Error error; data = decoder->conv_state.Convert(dc->in_audio_format, data, length, dc->out_audio_format, &length, - &error); + error); if (data == NULL) { /* the PCM conversion has failed - stop playback, since we have no better way to bail out */ - g_warning("%s", error->message); + g_warning("%s", error.GetMessage()); return DECODE_COMMAND_STOP; } } |