2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2015-01-01 19:48:13 +01:00
|
|
|
* Copyright (C) 2003-2015 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-06-16 23:52:59 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-06-16 23:52:59 +02:00
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2013-01-30 17:18:48 +01:00
|
|
|
#include "DecoderList.hxx"
|
2013-07-28 13:18:48 +02:00
|
|
|
#include "DecoderPlugin.hxx"
|
2014-01-24 00:20:01 +01:00
|
|
|
#include "config/ConfigGlobal.hxx"
|
2015-01-21 21:14:25 +01:00
|
|
|
#include "config/Param.hxx"
|
2014-01-24 00:02:24 +01:00
|
|
|
#include "plugins/AudiofileDecoderPlugin.hxx"
|
|
|
|
#include "plugins/PcmDecoderPlugin.hxx"
|
|
|
|
#include "plugins/DsdiffDecoderPlugin.hxx"
|
|
|
|
#include "plugins/DsfDecoderPlugin.hxx"
|
|
|
|
#include "plugins/FlacDecoderPlugin.h"
|
|
|
|
#include "plugins/OpusDecoderPlugin.h"
|
|
|
|
#include "plugins/VorbisDecoderPlugin.h"
|
|
|
|
#include "plugins/AdPlugDecoderPlugin.h"
|
|
|
|
#include "plugins/WavpackDecoderPlugin.hxx"
|
|
|
|
#include "plugins/FfmpegDecoderPlugin.hxx"
|
|
|
|
#include "plugins/GmeDecoderPlugin.hxx"
|
|
|
|
#include "plugins/FaadDecoderPlugin.hxx"
|
|
|
|
#include "plugins/MadDecoderPlugin.hxx"
|
|
|
|
#include "plugins/SndfileDecoderPlugin.hxx"
|
|
|
|
#include "plugins/Mpg123DecoderPlugin.hxx"
|
|
|
|
#include "plugins/WildmidiDecoderPlugin.hxx"
|
|
|
|
#include "plugins/MikmodDecoderPlugin.hxx"
|
|
|
|
#include "plugins/ModplugDecoderPlugin.hxx"
|
|
|
|
#include "plugins/MpcdecDecoderPlugin.hxx"
|
|
|
|
#include "plugins/FluidsynthDecoderPlugin.hxx"
|
|
|
|
#include "plugins/SidplayDecoderPlugin.hxx"
|
2013-10-15 22:04:17 +02:00
|
|
|
#include "util/Macros.hxx"
|
2004-05-30 22:25:08 +02:00
|
|
|
|
2009-02-15 17:48:37 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2013-10-21 20:31:34 +02:00
|
|
|
const struct DecoderPlugin *const decoder_plugins[] = {
|
2014-11-22 23:18:07 +01:00
|
|
|
#ifdef ENABLE_MAD
|
2009-02-16 19:30:45 +01:00
|
|
|
&mad_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2014-11-21 22:19:57 +01:00
|
|
|
#ifdef ENABLE_MPG123
|
2009-08-26 20:08:13 +02:00
|
|
|
&mpg123_decoder_plugin,
|
|
|
|
#endif
|
2009-04-01 22:45:17 +02:00
|
|
|
#ifdef ENABLE_VORBIS_DECODER
|
2009-01-14 23:09:02 +01:00
|
|
|
&vorbis_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2014-11-21 22:19:57 +01:00
|
|
|
#ifdef ENABLE_FLAC
|
2009-01-15 19:50:28 +01:00
|
|
|
&oggflac_decoder_plugin,
|
|
|
|
&flac_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2014-11-21 22:19:57 +01:00
|
|
|
#ifdef ENABLE_OPUS
|
2012-09-04 09:26:18 +02:00
|
|
|
&opus_decoder_plugin,
|
|
|
|
#endif
|
2009-07-07 08:58:51 +02:00
|
|
|
#ifdef ENABLE_SNDFILE
|
|
|
|
&sndfile_decoder_plugin,
|
|
|
|
#endif
|
2014-11-21 22:19:57 +01:00
|
|
|
#ifdef ENABLE_AUDIOFILE
|
2009-04-03 00:52:13 +02:00
|
|
|
&audiofile_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2014-09-26 09:00:58 +02:00
|
|
|
#ifdef ENABLE_DSD
|
2011-10-03 12:52:15 +02:00
|
|
|
&dsdiff_decoder_plugin,
|
2012-06-16 13:46:42 +02:00
|
|
|
&dsf_decoder_plugin,
|
2014-09-26 09:00:58 +02:00
|
|
|
#endif
|
2014-12-09 21:36:52 +01:00
|
|
|
#ifdef ENABLE_FAAD
|
2009-02-16 19:30:54 +01:00
|
|
|
&faad_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2014-12-09 21:07:05 +01:00
|
|
|
#ifdef ENABLE_MPCDEC
|
2009-02-17 08:48:20 +01:00
|
|
|
&mpcdec_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2014-11-21 22:19:57 +01:00
|
|
|
#ifdef ENABLE_WAVPACK
|
2009-04-03 00:52:13 +02:00
|
|
|
&wavpack_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2014-11-21 22:19:57 +01:00
|
|
|
#ifdef ENABLE_MODPLUG
|
2009-04-03 00:52:13 +02:00
|
|
|
&modplug_decoder_plugin,
|
2008-12-28 17:11:18 +01:00
|
|
|
#endif
|
2009-04-01 22:48:06 +02:00
|
|
|
#ifdef ENABLE_MIKMOD_DECODER
|
2009-01-24 20:18:44 +01:00
|
|
|
&mikmod_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2009-02-11 20:31:17 +01:00
|
|
|
#ifdef ENABLE_SIDPLAY
|
|
|
|
&sidplay_decoder_plugin,
|
|
|
|
#endif
|
2009-02-12 16:43:18 +01:00
|
|
|
#ifdef ENABLE_WILDMIDI
|
|
|
|
&wildmidi_decoder_plugin,
|
|
|
|
#endif
|
2009-04-05 06:31:55 +02:00
|
|
|
#ifdef ENABLE_FLUIDSYNTH
|
|
|
|
&fluidsynth_decoder_plugin,
|
|
|
|
#endif
|
2014-11-21 22:19:57 +01:00
|
|
|
#ifdef ENABLE_ADPLUG
|
2012-09-25 22:03:44 +02:00
|
|
|
&adplug_decoder_plugin,
|
|
|
|
#endif
|
2014-11-21 22:19:57 +01:00
|
|
|
#ifdef ENABLE_FFMPEG
|
2009-04-03 00:52:13 +02:00
|
|
|
&ffmpeg_decoder_plugin,
|
2010-04-10 10:05:16 +02:00
|
|
|
#endif
|
2014-12-22 10:28:15 +01:00
|
|
|
#ifdef ENABLE_GME
|
2010-04-10 10:05:16 +02:00
|
|
|
&gme_decoder_plugin,
|
2008-11-01 14:53:30 +01:00
|
|
|
#endif
|
2010-12-22 09:08:12 +01:00
|
|
|
&pcm_decoder_plugin,
|
2013-10-19 18:19:03 +02:00
|
|
|
nullptr
|
2008-11-01 14:53:30 +01:00
|
|
|
};
|
2004-05-31 22:59:55 +02:00
|
|
|
|
2013-10-15 22:04:17 +02:00
|
|
|
static constexpr unsigned num_decoder_plugins =
|
|
|
|
ARRAY_SIZE(decoder_plugins) - 1;
|
2004-05-30 22:25:08 +02:00
|
|
|
|
2008-11-01 14:53:30 +01:00
|
|
|
/** which plugins have been initialized successfully? */
|
2009-11-07 15:46:45 +01:00
|
|
|
bool decoder_plugins_enabled[num_decoder_plugins];
|
2004-05-30 22:25:08 +02:00
|
|
|
|
2013-10-21 20:31:34 +02:00
|
|
|
const struct DecoderPlugin *
|
2008-11-01 14:51:41 +01:00
|
|
|
decoder_plugin_from_name(const char *name)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-10-22 00:59:46 +02:00
|
|
|
return decoder_plugins_find([=](const DecoderPlugin &plugin){
|
2013-10-21 22:02:19 +02:00
|
|
|
return strcmp(plugin.name, name) == 0;
|
|
|
|
});
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
|
|
|
|
2008-08-26 08:27:09 +02:00
|
|
|
void decoder_plugin_init_all(void)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-08-04 11:30:26 +02:00
|
|
|
struct config_param empty;
|
|
|
|
|
2013-10-19 18:19:03 +02:00
|
|
|
for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i) {
|
2013-10-21 20:31:34 +02:00
|
|
|
const DecoderPlugin &plugin = *decoder_plugins[i];
|
2009-02-15 18:35:19 +01:00
|
|
|
const struct config_param *param =
|
2015-01-21 22:36:13 +01:00
|
|
|
config_find_block(ConfigOption::DECODER, "plugin",
|
|
|
|
plugin.name);
|
2009-02-15 18:33:28 +01:00
|
|
|
|
2013-08-04 11:30:26 +02:00
|
|
|
if (param == nullptr)
|
|
|
|
param = ∅
|
|
|
|
else if (!param->GetBlockValue("enabled", true))
|
2009-02-15 18:40:47 +01:00
|
|
|
/* the plugin is disabled in mpd.conf */
|
|
|
|
continue;
|
|
|
|
|
2013-10-21 20:36:34 +02:00
|
|
|
if (plugin.Init(*param))
|
2008-11-01 14:53:30 +01:00
|
|
|
decoder_plugins_enabled[i] = true;
|
|
|
|
}
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
|
|
|
|
2008-08-26 08:27:09 +02:00
|
|
|
void decoder_plugin_deinit_all(void)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-10-21 22:02:19 +02:00
|
|
|
decoder_plugins_for_each_enabled([=](const DecoderPlugin &plugin){
|
|
|
|
plugin.Finish();
|
|
|
|
});
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
2013-12-29 16:18:33 +01:00
|
|
|
|
|
|
|
bool
|
|
|
|
decoder_plugins_supports_suffix(const char *suffix)
|
|
|
|
{
|
|
|
|
return decoder_plugins_try([suffix](const DecoderPlugin &plugin){
|
|
|
|
return plugin.SupportsSuffix(suffix);
|
|
|
|
});
|
|
|
|
}
|