diff options
Diffstat (limited to '')
-rw-r--r-- | src/decode.c | 100 |
1 files changed, 24 insertions, 76 deletions
diff --git a/src/decode.c b/src/decode.c index d5d3ab41b..ec4774fa9 100644 --- a/src/decode.c +++ b/src/decode.c @@ -28,23 +28,6 @@ #include "sig_handlers.h" #include "ls.h" -#ifdef HAVE_MAD -#include "mp3_decode.h" -#endif -#ifdef HAVE_OGG -#include "ogg_decode.h" -#endif -#ifdef HAVE_FLAC -#include "flac_decode.h" -#endif -#ifdef HAVE_AUDIOFILE -#include "audiofile_decode.h" -#endif -#ifdef HAVE_FAAD -#include "mp4_decode.h" -#include "aac_decode.h" -#endif - #include <signal.h> #include <sys/types.h> #include <sys/time.h> @@ -255,8 +238,7 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { int ret; InputStream inStream; - int suffix = pc->fileSuffix; - int decodeType = pc->decodeType; + InputPlugin * plugin; strncpy(dc->file,pc->file,MAXPATHLEN); dc->file[MAXPATHLEN] = '\0'; @@ -282,67 +264,33 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { return; } - switch(decodeType) { - case DECODE_TYPE_URL: -#ifdef HAVE_OGG - if(suffix == DECODE_SUFFIX_OGG || (inStream.mime && - 0 == strcmp(inStream.mime, "application/ogg"))) - { - ret = ogg_decode(cb, dc, &inStream); - break; + ret = DECODE_ERROR_UNKTYPE; + if(isRemoteUrl(pc->file)) { + plugin = getInputPluginFromMimeType(inStream.mime); + if(plugin == NULL) { + plugin = getInputPluginFromSuffix(getSuffix(dc->file)); } -#endif -#ifdef HAVE_MAD - /*if(fileSuffix == DECODE_SUFFIX_MP3 || (inStream.mime && - 0 == strcmp(inStream.mime, "audio/mpeg")))*/ + if(plugin && (plugin->streamTypes & INPUT_PLUGIN_STREAM_URL) && + plugin->streamDecodeFunc) { - ret = mp3_decode(cb, dc, &inStream, 0); - break; - } - ret = DECODE_ERROR_UNKTYPE; -#endif - case DECODE_TYPE_FILE: -#ifdef HAVE_MAD - if(suffix == DECODE_SUFFIX_MP3) { - ret = mp3_decode(cb, dc, &inStream, 1); - break; - } -#endif -#ifdef HAVE_OGG - if(suffix == DECODE_SUFFIX_OGG) { - ret = ogg_decode(cb, dc, &inStream); - break; - } -#endif -#ifdef HAVE_FAAD - if(suffix == DECODE_SUFFIX_AAC) { - closeInputStream(&inStream); - ret = aac_decode(cb,dc); - break; - } - if(suffix == DECODE_SUFFIX_MP4) { - closeInputStream(&inStream); - ret = mp4_decode(cb,dc); - break; - } -#endif -#ifdef HAVE_FLAC - if(suffix == DECODE_SUFFIX_FLAC) { - closeInputStream(&inStream); - ret = flac_decode(cb,dc); - break; - } -#endif -#ifdef HAVE_AUDIOFILE - if(suffix == DECODE_SUFFIX_WAVE) { - closeInputStream(&inStream); - ret = audiofile_decode(cb,dc); - break; + ret = plugin->streamDecodeFunc(cb, dc, &inStream); } -#endif - default: - ret = DECODE_ERROR_UNKTYPE; } + else { + plugin = getInputPluginFromSuffix(getSuffix(dc->file)); + 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); + } + } + } + if(ret<0 || ret == DECODE_ERROR_UNKTYPE) { strncpy(pc->erroredFile, dc->file, MAXPATHLEN); pc->erroredFile[MAXPATHLEN] = '\0'; |