diff options
Diffstat (limited to '')
-rw-r--r-- | src/decoder/wavpack_plugin.c | 27 | ||||
-rw-r--r-- | src/decoder_thread.c | 42 |
2 files changed, 35 insertions, 34 deletions
diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c index 3eb2b0e68..1615d70d0 100644 --- a/src/decoder/wavpack_plugin.c +++ b/src/decoder/wavpack_plugin.c @@ -464,13 +464,12 @@ wavpack_input_init(struct wavpack_input *isp, struct decoder *decoder, isp->last_byte = EOF; } -static bool -wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc, - struct wavpack_input *wpi) +static struct input_stream * +wavpack_open_wvc(struct decoder *decoder, struct wavpack_input *wpi) { + struct input_stream *is_wvc; char *utf8url; char *wvc_url = NULL; - bool ret; char first_byte; size_t nbytes; @@ -486,12 +485,11 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc, wvc_url = g_strconcat(utf8url, "c", NULL); g_free(utf8url); - ret = input_stream_open(is_wvc, wvc_url, NULL); + is_wvc = input_stream_open(wvc_url, NULL); g_free(wvc_url); - if (!ret) { - return false; - } + if (is_wvc == NULL) + return NULL; /* * And we try to buffer in order to get know @@ -502,13 +500,13 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc, ); if (nbytes == 0) { input_stream_close(is_wvc); - return false; + return NULL; } /* push it back */ wavpack_input_init(wpi, decoder, is_wvc); wpi->last_byte = first_byte; - return true; + return is_wvc; } /* @@ -519,14 +517,15 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is) { char error[ERRORLEN]; WavpackContext *wpc; - struct input_stream is_wvc; + struct input_stream *is_wvc; int open_flags = OPEN_NORMALIZE; struct wavpack_input isp, isp_wvc; bool can_seek = is->seekable; - if (wavpack_open_wvc(decoder, &is_wvc, &isp_wvc)) { + is_wvc = wavpack_open_wvc(decoder, &isp_wvc); + if (is_wvc != NULL) { open_flags |= OPEN_WVC; - can_seek &= is_wvc.seekable; + can_seek &= is_wvc->seekable; } if (!can_seek) { @@ -549,7 +548,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is) WavpackCloseFile(wpc); if (open_flags & OPEN_WVC) { - input_stream_close(&is_wvc); + input_stream_close(is_wvc); } } diff --git a/src/decoder_thread.c b/src/decoder_thread.c index 7e9c820d2..de095216a 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -56,22 +56,23 @@ decoder_lock_get_command(struct decoder_control *dc) * * Unlock the decoder before calling this function. * - * @return true on success of if #DECODE_COMMAND_STOP is received, - * false on error + * @return an input_stream on success or if #DECODE_COMMAND_STOP is + * received, NULL on error */ -static bool -decoder_input_stream_open(struct decoder_control *dc, - struct input_stream *is, const char *uri) +static struct input_stream * +decoder_input_stream_open(struct decoder_control *dc, const char *uri) { GError *error = NULL; + struct input_stream *is; - if (!input_stream_open(is, uri, &error)) { + is = input_stream_open(uri, &error); + if (is == NULL) { if (error != NULL) { g_warning("%s", error->message); g_error_free(error); } - return false; + return NULL; } /* wait for the input stream to become ready; its metadata @@ -86,11 +87,11 @@ decoder_input_stream_open(struct decoder_control *dc, input_stream_close(is); g_warning("%s", error->message); g_error_free(error); - return false; + return NULL; } } - return true; + return is; } static bool @@ -215,12 +216,13 @@ static bool decoder_run_stream(struct decoder *decoder, const char *uri) { struct decoder_control *dc = decoder->dc; - struct input_stream input_stream; + struct input_stream *input_stream; bool success; decoder_unlock(dc); - if (!decoder_input_stream_open(dc, &input_stream, uri)) { + input_stream = decoder_input_stream_open(dc, uri); + if (input_stream == NULL) { decoder_lock(dc); return false; } @@ -229,15 +231,15 @@ decoder_run_stream(struct decoder *decoder, const char *uri) success = dc->command == DECODE_COMMAND_STOP || /* first we try mime types: */ - decoder_run_stream_mime_type(decoder, &input_stream) || + decoder_run_stream_mime_type(decoder, input_stream) || /* if that fails, try suffix matching the URL: */ - decoder_run_stream_suffix(decoder, &input_stream, uri) || + decoder_run_stream_suffix(decoder, input_stream, uri) || /* fallback to mp3: this is needed for bastard streams that don't have a suffix or set the mimeType */ - decoder_run_stream_fallback(decoder, &input_stream); + decoder_run_stream_fallback(decoder, input_stream); decoder_unlock(dc); - input_stream_close(&input_stream); + input_stream_close(input_stream); decoder_lock(dc); return success; @@ -267,21 +269,21 @@ decoder_run_file(struct decoder *decoder, const char *path_fs) decoder_unlock(dc); } else if (plugin->stream_decode != NULL) { - struct input_stream input_stream; + struct input_stream *input_stream; bool success; - if (!decoder_input_stream_open(dc, &input_stream, - path_fs)) + input_stream = decoder_input_stream_open(dc, path_fs); + if (input_stream == NULL) continue; decoder_lock(dc); success = decoder_stream_decode(plugin, decoder, - &input_stream); + input_stream); decoder_unlock(dc); - input_stream_close(&input_stream); + input_stream_close(input_stream); if (success) { decoder_lock(dc); |