From 2124df13909a2413dfc41684323f4cee78283c31 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 2 Nov 2008 17:10:02 +0100 Subject: decoder: rewind input stream after try_decode() The try_decode() method may have read some data from the stream, which is now lost. To make this data available to other methods, get it back by rewinding the input stream after each try_decode() invocation. The ogg and wavpack plugins did this manually and inconsistently; this code can now be removed. --- src/decoder_thread.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/decoder_thread.c') diff --git a/src/decoder_thread.c b/src/decoder_thread.c index 403c2bac8..d66094cd2 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -32,10 +32,17 @@ static bool decoder_try_decode(const struct decoder_plugin *plugin, struct input_stream *input_stream) { + bool ret; + if (plugin->try_decode == NULL) return true; - return plugin->try_decode(input_stream); + ret = plugin->try_decode(input_stream); + + /* rewind the stream, so the next reader gets a fresh start */ + input_stream_seek(input_stream, 0, SEEK_SET); + + return ret; } static void decodeStart(void) -- cgit v1.2.3