DecoderPlugin: pass config_param reference
This commit is contained in:
parent
83f4c48c8a
commit
7a1d466fb2
|
@ -201,8 +201,7 @@ decoder_plugin_config(const char *plugin_name)
|
|||
const struct config_param *param = NULL;
|
||||
|
||||
while ((param = config_get_next_param(CONF_DECODER, param)) != NULL) {
|
||||
const char *name =
|
||||
config_get_block_string(param, "plugin", NULL);
|
||||
const char *name = param->GetBlockValue("plugin");
|
||||
if (name == NULL)
|
||||
MPD_ERROR("decoder configuration without 'plugin' name in line %d",
|
||||
param->line);
|
||||
|
@ -216,16 +215,20 @@ decoder_plugin_config(const char *plugin_name)
|
|||
|
||||
void decoder_plugin_init_all(void)
|
||||
{
|
||||
struct config_param empty;
|
||||
|
||||
for (unsigned i = 0; decoder_plugins[i] != NULL; ++i) {
|
||||
const struct decoder_plugin *plugin = decoder_plugins[i];
|
||||
const struct config_param *param =
|
||||
decoder_plugin_config(plugin->name);
|
||||
|
||||
if (!config_get_block_bool(param, "enabled", true))
|
||||
if (param == nullptr)
|
||||
param = ∅
|
||||
else if (!param->GetBlockValue("enabled", true))
|
||||
/* the plugin is disabled in mpd.conf */
|
||||
continue;
|
||||
|
||||
if (decoder_plugin_init(plugin, param))
|
||||
if (decoder_plugin_init(plugin, *param))
|
||||
decoder_plugins_enabled[i] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ struct decoder_plugin {
|
|||
* @return true if the plugin was initialized successfully,
|
||||
* false if the plugin is not available
|
||||
*/
|
||||
bool (*init)(const struct config_param *param);
|
||||
bool (*init)(const config_param ¶m);
|
||||
|
||||
/**
|
||||
* Deinitialize a decoder plugin which was initialized
|
||||
|
@ -112,7 +112,7 @@ struct decoder_plugin {
|
|||
*/
|
||||
static inline bool
|
||||
decoder_plugin_init(const struct decoder_plugin *plugin,
|
||||
const struct config_param *param)
|
||||
const config_param ¶m)
|
||||
{
|
||||
return plugin->init != nullptr
|
||||
? plugin->init(param)
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
static unsigned sample_rate;
|
||||
|
||||
static bool
|
||||
adplug_init(const struct config_param *param)
|
||||
adplug_init(const config_param ¶m)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
sample_rate = config_get_block_unsigned(param, "sample_rate", 48000);
|
||||
sample_rate = param.GetBlockValue("sample_rate", 48000u);
|
||||
if (!audio_check_sample_rate(sample_rate, &error)) {
|
||||
g_warning("%s\n", error->message);
|
||||
g_error_free(error);
|
||||
|
|
|
@ -84,9 +84,9 @@ struct DsdiffMetaData {
|
|||
static bool lsbitfirst;
|
||||
|
||||
static bool
|
||||
dsdiff_init(const struct config_param *param)
|
||||
dsdiff_init(const config_param ¶m)
|
||||
{
|
||||
lsbitfirst = config_get_block_bool(param, "lsbitfirst", false);
|
||||
lsbitfirst = param.GetBlockValue("lsbitfirst", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ mpd_ffmpeg_stream_close(struct mpd_ffmpeg_stream *stream)
|
|||
}
|
||||
|
||||
static bool
|
||||
ffmpeg_init(G_GNUC_UNUSED const struct config_param *param)
|
||||
ffmpeg_init(gcc_unused const config_param ¶m)
|
||||
{
|
||||
av_log_set_callback(mpd_ffmpeg_log_callback);
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ flac_decode(struct decoder * decoder, struct input_stream *input_stream)
|
|||
}
|
||||
|
||||
static bool
|
||||
oggflac_init(G_GNUC_UNUSED const struct config_param *param)
|
||||
oggflac_init(gcc_unused const config_param ¶m)
|
||||
{
|
||||
return !!FLAC_API_SUPPORTS_OGG_FLAC;
|
||||
}
|
||||
|
|
|
@ -71,20 +71,19 @@ fluidsynth_mpd_log_function(int level, char *message, G_GNUC_UNUSED void *data)
|
|||
}
|
||||
|
||||
static bool
|
||||
fluidsynth_init(const struct config_param *param)
|
||||
fluidsynth_init(const config_param ¶m)
|
||||
{
|
||||
GError *error = nullptr;
|
||||
|
||||
sample_rate = config_get_block_unsigned(param, "sample_rate", 48000);
|
||||
sample_rate = param.GetBlockValue("sample_rate", 48000u);
|
||||
if (!audio_check_sample_rate(sample_rate, &error)) {
|
||||
g_warning("%s\n", error->message);
|
||||
g_error_free(error);
|
||||
return false;
|
||||
}
|
||||
|
||||
soundfont_path =
|
||||
config_get_block_string(param, "soundfont",
|
||||
"/usr/share/sounds/sf2/FluidR3_GM.sf2");
|
||||
soundfont_path = param.GetBlockValue("soundfont",
|
||||
"/usr/share/sounds/sf2/FluidR3_GM.sf2");
|
||||
|
||||
fluid_set_log_function(LAST_LOG_LEVEL,
|
||||
fluidsynth_mpd_log_function, nullptr);
|
||||
|
|
|
@ -101,7 +101,7 @@ mad_fixed_to_24_buffer(int32_t *dest, const struct mad_synth *synth,
|
|||
}
|
||||
|
||||
static bool
|
||||
mp3_plugin_init(G_GNUC_UNUSED const struct config_param *param)
|
||||
mp3_plugin_init(gcc_unused const config_param ¶m)
|
||||
{
|
||||
gapless_playback = config_get_bool(CONF_GAPLESS_MP3_PLAYBACK,
|
||||
DEFAULT_GAPLESS_MP3_PLAYBACK);
|
||||
|
|
|
@ -106,15 +106,14 @@ static MDRIVER drv_mpd = {
|
|||
static unsigned mikmod_sample_rate;
|
||||
|
||||
static bool
|
||||
mikmod_decoder_init(const struct config_param *param)
|
||||
mikmod_decoder_init(const config_param ¶m)
|
||||
{
|
||||
static char params[] = "";
|
||||
|
||||
mikmod_sample_rate = config_get_block_unsigned(param, "sample_rate",
|
||||
44100);
|
||||
mikmod_sample_rate = param.GetBlockValue("sample_rate", 44100u);
|
||||
if (!audio_valid_sample_rate(mikmod_sample_rate))
|
||||
MPD_ERROR("Invalid sample rate in line %d: %u",
|
||||
param->line, mikmod_sample_rate);
|
||||
param.line, mikmod_sample_rate);
|
||||
|
||||
md_device = 0;
|
||||
md_reverb = 0;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#define G_LOG_DOMAIN "mpg123"
|
||||
|
||||
static bool
|
||||
mpd_mpg123_init(G_GNUC_UNUSED const struct config_param *param)
|
||||
mpd_mpg123_init(gcc_unused const config_param ¶m)
|
||||
{
|
||||
mpg123_init();
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ IsOpusTags(const ogg_packet &packet)
|
|||
}
|
||||
|
||||
static bool
|
||||
mpd_opus_init(G_GNUC_UNUSED const struct config_param *param)
|
||||
mpd_opus_init(gcc_unused const config_param ¶m)
|
||||
{
|
||||
g_debug("%s", opus_get_version_string());
|
||||
|
||||
|
|
|
@ -35,13 +35,13 @@ extern "C" {
|
|||
static constexpr unsigned WILDMIDI_SAMPLE_RATE = 48000;
|
||||
|
||||
static bool
|
||||
wildmidi_init(const struct config_param *param)
|
||||
wildmidi_init(const config_param ¶m)
|
||||
{
|
||||
const char *config_file;
|
||||
int ret;
|
||||
|
||||
config_file = config_get_block_string(param, "config_file",
|
||||
"/etc/timidity/timidity.cfg");
|
||||
config_file = param.GetBlockValue("config_file",
|
||||
"/etc/timidity/timidity.cfg");
|
||||
if (!g_file_test(config_file, G_FILE_TEST_IS_REGULAR)) {
|
||||
g_debug("configuration file does not exist: %s", config_file);
|
||||
return false;
|
||||
|
|
|
@ -83,24 +83,22 @@ sidplay_load_songlength_db(const char *path)
|
|||
}
|
||||
|
||||
static bool
|
||||
sidplay_init(const struct config_param *param)
|
||||
sidplay_init(const config_param ¶m)
|
||||
{
|
||||
/* read the songlengths database file */
|
||||
songlength_file=config_get_block_string(param,
|
||||
"songlength_database", NULL);
|
||||
songlength_file = param.GetBlockValue("songlength_database");
|
||||
if (songlength_file != NULL)
|
||||
songlength_database = sidplay_load_songlength_db(songlength_file);
|
||||
|
||||
default_songlength=config_get_block_unsigned(param,
|
||||
"default_songlength", 0);
|
||||
default_songlength = param.GetBlockValue("default_songlength", 0u);
|
||||
|
||||
all_files_are_containers=config_get_block_bool(param,
|
||||
"all_files_are_containers", true);
|
||||
all_files_are_containers =
|
||||
param.GetBlockValue("all_files_are_containers", true);
|
||||
|
||||
path_with_subtune=g_pattern_spec_new(
|
||||
"*/" SUBTUNE_PREFIX "???.sid");
|
||||
|
||||
filter_setting=config_get_block_bool(param, "filter", true);
|
||||
filter_setting = param.GetBlockValue("filter", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue