aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-10 15:02:47 +0100
committerMax Kellermann <max@duempel.org>2008-11-10 15:02:47 +0100
commit10eea9d9815c37077d0d0bde98ae4daeed3d101b (patch)
tree2e4d4ae592ab6d5ff01b0af1bcca349e15a952e2 /src
parentcad37b2e5a1cbd9af54b1e1fe24f17de22e11a0d (diff)
downloadmpd-10eea9d9815c37077d0d0bde98ae4daeed3d101b.tar.gz
mpd-10eea9d9815c37077d0d0bde98ae4daeed3d101b.tar.xz
mpd-10eea9d9815c37077d0d0bde98ae4daeed3d101b.zip
decoder: fall back to next plugin
When a plugin is unable to decode a song, try the other plugins.
Diffstat (limited to 'src')
-rw-r--r--src/decoder_thread.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index ac1b41b6f..a50dbf8d2 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -60,6 +60,9 @@ decoder_stream_decode(const struct decoder_plugin *plugin,
assert(input_stream->ready);
assert(dc.state == DECODE_STATE_START);
+ /* rewind the stream, so each plugin gets a fresh start */
+ input_stream_seek(input_stream, 0, SEEK_SET);
+
ret = plugin->stream_decode(decoder, input_stream);
if (ret) {
@@ -173,7 +176,10 @@ static void decoder_run(void)
continue;
ret = decoder_stream_decode(plugin, &decoder,
&input_stream);
- break;
+ if (ret)
+ break;
+
+ plugin = NULL;
}
/* if that fails, try suffix matching the URL: */
@@ -187,7 +193,11 @@ static void decoder_run(void)
continue;
ret = decoder_stream_decode(plugin, &decoder,
&input_stream);
- break;
+ if (ret)
+ break;
+
+ assert(dc.state == DECODE_STATE_START);
+ plugin = NULL;
}
}
/* fallback to mp3: */
@@ -213,11 +223,13 @@ static void decoder_run(void)
close_instream = false;
ret = decoder_file_decode(plugin,
&decoder, uri);
- break;
+ if (ret)
+ break;
} else if (plugin->stream_decode != NULL) {
ret = decoder_stream_decode(plugin, &decoder,
&input_stream);
- break;
+ if (ret)
+ break;
}
}
}