aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-03-16 06:52:46 +0000
committerEric Wong <normalperson@yhbt.net>2006-03-16 06:52:46 +0000
commit69635022133488e6b19569fb59b16c4658a244eb (patch)
treea7149e6a5a82017ae3821c801433c8794f796aec /src/decode.c
parentd7e846bdc2d848525ebd4251c4c5d9c5fe0d2705 (diff)
downloadmpd-69635022133488e6b19569fb59b16c4658a244eb.tar.gz
mpd-69635022133488e6b19569fb59b16c4658a244eb.tar.xz
mpd-69635022133488e6b19569fb59b16c4658a244eb.zip
merge with mpd/trunk up to r3925
git-svn-id: https://svn.musicpd.org/mpd/trunk@3926 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/decode.c')
-rw-r--r--src/decode.c81
1 files changed, 60 insertions, 21 deletions
diff --git a/src/decode.c b/src/decode.c
index 25b34ded8..146f5a974 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -322,37 +322,76 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
ret = DECODE_ERROR_UNKTYPE;
if(isRemoteUrl(dc->utf8url)) {
+ unsigned int next = 0;
cb->acceptMetadata = 1;
- plugin = getInputPluginFromMimeType(inStream.mime);
+
+ /* first we try mime types: */
+ while(ret && (plugin = getInputPluginFromMimeType(
+ inStream.mime, next++))) {
+ if (!plugin->streamDecodeFunc)
+ continue;
+ if (!(plugin->streamTypes & INPUT_PLUGIN_STREAM_URL))
+ continue;
+ if(plugin->tryDecodeFunc && !plugin->tryDecodeFunc(
+ &inStream))
+ continue;
+ ret = plugin->streamDecodeFunc(cb, dc, &inStream);
+ break;
+ }
+
+ /* if that fails, try suffix matching the URL: */
if(plugin == NULL) {
- plugin = getInputPluginFromSuffix(
- getSuffix(dc->utf8url));
+ char * s = getSuffix(dc->utf8url);
+ next = 0;
+ while(ret && (plugin = getInputPluginFromSuffix(
+ s, next++))) {
+ if (!plugin->streamDecodeFunc)
+ continue;
+ if(!(plugin->streamTypes &
+ INPUT_PLUGIN_STREAM_URL))
+ continue;
+ if(plugin->tryDecodeFunc &&
+ !plugin->tryDecodeFunc(
+ &inStream))
+ continue;
+ ret = plugin->streamDecodeFunc(
+ cb, dc, &inStream);
+ break;
+ }
}
+ /* fallback to mp3: */
/* this is needed for bastard streams that don't have a suffix
or set the mimeType */
if(plugin == NULL) {
- plugin = getInputPluginFromName("mp3");
- }
- if(plugin && (plugin->streamTypes & INPUT_PLUGIN_STREAM_URL) &&
- plugin->streamDecodeFunc)
- {
- ret = plugin->streamDecodeFunc(cb, dc, &inStream);
+ /* we already know our mp3Plugin supports streams, no
+ * need to check for stream{Types,DecodeFunc} */
+ if ((plugin = getInputPluginFromName("mp3")))
+ ret = plugin->streamDecodeFunc(cb, dc,
+ &inStream);
}
}
else {
+ unsigned int next = 0;
+ char * s = getSuffix(dc->utf8url);
cb->acceptMetadata = 0;
- plugin = getInputPluginFromSuffix(getSuffix(dc->utf8url));
- if(plugin && (plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE))
- {
- if(plugin->streamDecodeFunc) {
- ret = plugin->streamDecodeFunc(cb, dc,
- &inStream);
- }
- else if(plugin->fileDecodeFunc) {
- closeInputStream(&inStream);
- ret = plugin->fileDecodeFunc(cb, dc, path);
- }
- }
+ while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
+ if(!plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE)
+ continue;
+ if(plugin->tryDecodeFunc && !plugin->tryDecodeFunc(
+ &inStream))
+ continue;
+
+ if(plugin->streamDecodeFunc) {
+ ret = plugin->streamDecodeFunc(
+ cb, dc, &inStream);
+ break;
+ }
+ else if(plugin->fileDecodeFunc) {
+ closeInputStream(&inStream);
+ ret = plugin->fileDecodeFunc(
+ cb, dc, path);
+ }
+ }
}
if(ret<0 || ret == DECODE_ERROR_UNKTYPE) {