From 4eeea640f4641ec7c2b303567adf3e79855eb885 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 22 May 2014 11:10:41 +0200 Subject: DecoderAPI: add function decoder_open_uri() Move and refactor code from the Wavpack decoder plugin. --- test/FakeDecoderAPI.cxx | 6 ++++++ test/FakeDecoderAPI.hxx | 5 +++++ test/run_decoder.cxx | 7 ++----- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/FakeDecoderAPI.cxx b/test/FakeDecoderAPI.cxx index 155e7d5df..7aa24c4df 100644 --- a/test/FakeDecoderAPI.cxx +++ b/test/FakeDecoderAPI.cxx @@ -66,6 +66,12 @@ decoder_seek_error(gcc_unused Decoder &decoder) { } +InputStream * +decoder_open_uri(Decoder &decoder, const char *uri, Error &error) +{ + return InputStream::OpenReady(uri, decoder.mutex, decoder.cond, error); +} + size_t decoder_read(gcc_unused Decoder *decoder, InputStream &is, diff --git a/test/FakeDecoderAPI.hxx b/test/FakeDecoderAPI.hxx index 134e77117..6f1933977 100644 --- a/test/FakeDecoderAPI.hxx +++ b/test/FakeDecoderAPI.hxx @@ -21,8 +21,13 @@ #define FAKE_DECODER_API_HXX #include "check.h" +#include "thread/Mutex.hxx" +#include "thread/Cond.hxx" struct Decoder { + Mutex mutex; + Cond cond; + bool initialized; Decoder() diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx index b1c739405..3980340cc 100644 --- a/test/run_decoder.cxx +++ b/test/run_decoder.cxx @@ -27,7 +27,6 @@ #include "fs/Path.hxx" #include "AudioFormat.hxx" #include "util/Error.hxx" -#include "thread/Cond.hxx" #include "Log.hxx" #include "stdbin.h" @@ -77,11 +76,9 @@ int main(int argc, char **argv) if (plugin->file_decode != nullptr) { plugin->FileDecode(decoder, Path::FromFS(uri)); } else if (plugin->stream_decode != nullptr) { - Mutex mutex; - Cond cond; - InputStream *is = - InputStream::OpenReady(uri, mutex, cond, error); + InputStream::OpenReady(uri, decoder.mutex, + decoder.cond, error); if (is == NULL) { if (error.IsDefined()) LogError(error); -- cgit v1.2.3