diff --git a/src/decoder/Client.hxx b/src/decoder/Client.hxx index 15710a3ca..d77f2ed8e 100644 --- a/src/decoder/Client.hxx +++ b/src/decoder/Client.hxx @@ -23,6 +23,7 @@ #include "check.h" #include "DecoderCommand.hxx" #include "Chrono.hxx" +#include "input/Ptr.hxx" #include "Compiler.h" #include @@ -31,7 +32,6 @@ struct AudioFormat; struct Tag; struct ReplayGainInfo; class MixRampInfo; -class InputStream; /** * An interface between the decoder plugin and the MPD core. @@ -89,6 +89,15 @@ public: */ virtual void SeekError() = 0; + /** + * Open a new #InputStream and wait until it's ready. + * + * Throws #StopDecoder if DecoderCommand::STOP was received. + * + * Throws std::runtime_error on error. + */ + virtual InputStreamPtr OpenUri(const char *uri) = 0; + /** * Sets the time stamp for the next data chunk [seconds]. The MPD * core automatically counts it up, and a decoder plugin only needs to diff --git a/src/decoder/DecoderAPI.cxx b/src/decoder/DecoderAPI.cxx index 362df4e03..7db621142 100644 --- a/src/decoder/DecoderAPI.cxx +++ b/src/decoder/DecoderAPI.cxx @@ -251,14 +251,11 @@ Decoder::SeekError() } InputStreamPtr -decoder_open_uri(DecoderClient &client, const char *uri) +Decoder::OpenUri(const char *uri) { - auto &decoder = (Decoder &)client; + assert(dc.state == DecoderState::START || + dc.state == DecoderState::DECODE); - assert(decoder.dc.state == DecoderState::START || - decoder.dc.state == DecoderState::DECODE); - - DecoderControl &dc = decoder.dc; Mutex &mutex = dc.mutex; Cond &cond = dc.cond; diff --git a/src/decoder/DecoderAPI.hxx b/src/decoder/DecoderAPI.hxx index f2d010c16..91aea81e3 100644 --- a/src/decoder/DecoderAPI.hxx +++ b/src/decoder/DecoderAPI.hxx @@ -54,16 +54,6 @@ class DecoderClient; */ class StopDecoder {}; -/** - * Open a new #InputStream and wait until it's ready. - * - * Throws #StopDecoder if DecoderCommand::STOP was received. - * - * Throws std::runtime_error on error. - */ -InputStreamPtr -decoder_open_uri(DecoderClient &decoder, const char *uri); - /** * Blocking read from the input stream. * diff --git a/src/decoder/DecoderInternal.hxx b/src/decoder/DecoderInternal.hxx index 61576bd32..9155da501 100644 --- a/src/decoder/DecoderInternal.hxx +++ b/src/decoder/DecoderInternal.hxx @@ -124,6 +124,7 @@ struct Decoder final : DecoderClient { SongTime GetSeekTime() override; uint64_t GetSeekFrame() override; void SeekError() override; + InputStreamPtr OpenUri(const char *uri) override; void SubmitTimestamp(double t) override; DecoderCommand SubmitData(InputStream *is, const void *data, size_t length, diff --git a/src/decoder/plugins/WavpackDecoderPlugin.cxx b/src/decoder/plugins/WavpackDecoderPlugin.cxx index 685c1b66d..fb4ed7a16 100644 --- a/src/decoder/plugins/WavpackDecoderPlugin.cxx +++ b/src/decoder/plugins/WavpackDecoderPlugin.cxx @@ -496,7 +496,7 @@ wavpack_open_wvc(DecoderClient &client, const char *uri) }; try { - return decoder_open_uri(client, uri); + return client.OpenUri(uri); } catch (const std::runtime_error &) { return nullptr; } diff --git a/test/FakeDecoderAPI.cxx b/test/FakeDecoderAPI.cxx index 3c4539af1..cd8d52cf2 100644 --- a/test/FakeDecoderAPI.cxx +++ b/test/FakeDecoderAPI.cxx @@ -74,10 +74,9 @@ FakeDecoder::SeekError() } InputStreamPtr -decoder_open_uri(DecoderClient &client, const char *uri) +FakeDecoder::OpenUri(const char *uri) { - auto &decoder = (FakeDecoder &)client; - return InputStream::OpenReady(uri, decoder.mutex, decoder.cond); + return InputStream::OpenReady(uri, mutex, cond); } size_t diff --git a/test/FakeDecoderAPI.hxx b/test/FakeDecoderAPI.hxx index d21d1615d..5b9256a74 100644 --- a/test/FakeDecoderAPI.hxx +++ b/test/FakeDecoderAPI.hxx @@ -39,6 +39,7 @@ struct FakeDecoder final : DecoderClient { SongTime GetSeekTime() override; uint64_t GetSeekFrame() override; void SeekError() override; + InputStreamPtr OpenUri(const char *uri) override; void SubmitTimestamp(double t) override; DecoderCommand SubmitData(InputStream *is, const void *data, size_t length,