diff options
Diffstat (limited to '')
-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; } } |