summaryrefslogtreecommitdiff
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-09-08 20:48:04 +0200
committerMax Kellermann <max@musicpd.org>2016-09-08 20:54:55 +0200
commit25f736026457197c8b50e4378177dc4136a3c512 (patch)
tree9accd73a6f0266f17ffc153ddaf24ac33c0e25bc /src/decoder
parent78ec7d0fe102ce897360c93632953e0b78141efc (diff)
decoder/Thread: throw InputStream::Open() errors
Code simplification.
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/DecoderThread.cxx25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx
index f97934eb5..3acb8112d 100644
--- a/src/decoder/DecoderThread.cxx
+++ b/src/decoder/DecoderThread.cxx
@@ -52,15 +52,14 @@ static constexpr Domain decoder_thread_domain("decoder_thread");
* the stream gets ready.
*
* Unlock the decoder before calling this function.
- *
- * @return an InputStream on success, nullptr on error
*/
static InputStreamPtr
-decoder_input_stream_open(DecoderControl &dc, const char *uri, Error &error)
+decoder_input_stream_open(DecoderControl &dc, const char *uri)
{
+ Error error;
auto is = InputStream::Open(uri, dc.mutex, dc.cond, error);
if (is == nullptr)
- return nullptr;
+ throw error;
/* wait for the input stream to become ready; its metadata
will be available then */
@@ -78,17 +77,18 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri, Error &error)
}
if (!is->Check(error))
- return nullptr;
+ throw error;
return is;
}
static InputStreamPtr
-decoder_input_stream_open(DecoderControl &dc, Path path, Error &error)
+decoder_input_stream_open(DecoderControl &dc, Path path)
{
+ Error error;
auto is = OpenLocalInputStream(path, dc.mutex, dc.cond, error);
if (is == nullptr)
- return nullptr;
+ throw error;
assert(is->IsReady());
@@ -270,9 +270,8 @@ decoder_run_stream(Decoder &decoder, const char *uri)
{
DecoderControl &dc = decoder.dc;
- auto input_stream = decoder_input_stream_open(dc, uri, decoder.error);
- if (input_stream == nullptr)
- return false;
+ auto input_stream = decoder_input_stream_open(dc, uri);
+ assert(input_stream);
LoadReplayGain(decoder, *input_stream);
@@ -327,10 +326,8 @@ decoder_run_file(Decoder &decoder, const char *uri_utf8, Path path_fs)
if (suffix == nullptr)
return false;
- auto input_stream = decoder_input_stream_open(decoder.dc, path_fs,
- decoder.error);
- if (input_stream == nullptr)
- return false;
+ auto input_stream = decoder_input_stream_open(decoder.dc, path_fs);
+ assert(input_stream);
LoadReplayGain(decoder, *input_stream);