diff options
author | Max Kellermann <max@duempel.org> | 2013-08-04 11:30:26 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-04 13:30:47 +0200 |
commit | 7a1d466fb279659048e80e2853a7906c90d73235 (patch) | |
tree | f0c73e11b86b584a1a3f230507eabcf6f02986ea | |
parent | 83f4c48c8aaa46bbede4447c95939af310ea28ad (diff) | |
download | mpd-7a1d466fb279659048e80e2853a7906c90d73235.tar.gz mpd-7a1d466fb279659048e80e2853a7906c90d73235.tar.xz mpd-7a1d466fb279659048e80e2853a7906c90d73235.zip |
DecoderPlugin: pass config_param reference
-rw-r--r-- | src/DecoderList.cxx | 11 | ||||
-rw-r--r-- | src/DecoderPlugin.hxx | 4 | ||||
-rw-r--r-- | src/decoder/AdPlugDecoderPlugin.cxx | 4 | ||||
-rw-r--r-- | src/decoder/DsdiffDecoderPlugin.cxx | 4 | ||||
-rw-r--r-- | src/decoder/FfmpegDecoderPlugin.cxx | 2 | ||||
-rw-r--r-- | src/decoder/FlacDecoderPlugin.cxx | 2 | ||||
-rw-r--r-- | src/decoder/FluidsynthDecoderPlugin.cxx | 9 | ||||
-rw-r--r-- | src/decoder/MadDecoderPlugin.cxx | 2 | ||||
-rw-r--r-- | src/decoder/MikmodDecoderPlugin.cxx | 7 | ||||
-rw-r--r-- | src/decoder/Mpg123DecoderPlugin.cxx | 2 | ||||
-rw-r--r-- | src/decoder/OpusDecoderPlugin.cxx | 2 | ||||
-rw-r--r-- | src/decoder/WildmidiDecoderPlugin.cxx | 6 | ||||
-rw-r--r-- | src/decoder/sidplay_decoder_plugin.cxx | 14 |
13 files changed, 34 insertions, 35 deletions
diff --git a/src/DecoderList.cxx b/src/DecoderList.cxx index 0827586db..5c1a486df 100644 --- a/src/DecoderList.cxx +++ b/src/DecoderList.cxx @@ -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; } } diff --git a/src/DecoderPlugin.hxx b/src/DecoderPlugin.hxx index b250c4274..687447dee 100644 --- a/src/DecoderPlugin.hxx +++ b/src/DecoderPlugin.hxx @@ -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) diff --git a/src/decoder/AdPlugDecoderPlugin.cxx b/src/decoder/AdPlugDecoderPlugin.cxx index 37a95ce5d..47ab1a7f3 100644 --- a/src/decoder/AdPlugDecoderPlugin.cxx +++ b/src/decoder/AdPlugDecoderPlugin.cxx @@ -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); diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index 10b31a204..9e9dab4d2 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -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; } diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx index e4330f4d6..f42fc36a3 100644 --- a/src/decoder/FfmpegDecoderPlugin.cxx +++ b/src/decoder/FfmpegDecoderPlugin.cxx @@ -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); diff --git a/src/decoder/FlacDecoderPlugin.cxx b/src/decoder/FlacDecoderPlugin.cxx index 7becf73e5..d228c41b9 100644 --- a/src/decoder/FlacDecoderPlugin.cxx +++ b/src/decoder/FlacDecoderPlugin.cxx @@ -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; } diff --git a/src/decoder/FluidsynthDecoderPlugin.cxx b/src/decoder/FluidsynthDecoderPlugin.cxx index e559ad45e..7d56d4f1f 100644 --- a/src/decoder/FluidsynthDecoderPlugin.cxx +++ b/src/decoder/FluidsynthDecoderPlugin.cxx @@ -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); diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx index 04d171b9b..29abfafbd 100644 --- a/src/decoder/MadDecoderPlugin.cxx +++ b/src/decoder/MadDecoderPlugin.cxx @@ -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); diff --git a/src/decoder/MikmodDecoderPlugin.cxx b/src/decoder/MikmodDecoderPlugin.cxx index 3aa8a68ed..b7d113265 100644 --- a/src/decoder/MikmodDecoderPlugin.cxx +++ b/src/decoder/MikmodDecoderPlugin.cxx @@ -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; diff --git a/src/decoder/Mpg123DecoderPlugin.cxx b/src/decoder/Mpg123DecoderPlugin.cxx index 1aac825a2..05fe4717c 100644 --- a/src/decoder/Mpg123DecoderPlugin.cxx +++ b/src/decoder/Mpg123DecoderPlugin.cxx @@ -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(); diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx index 94c687317..b6835f760 100644 --- a/src/decoder/OpusDecoderPlugin.cxx +++ b/src/decoder/OpusDecoderPlugin.cxx @@ -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()); diff --git a/src/decoder/WildmidiDecoderPlugin.cxx b/src/decoder/WildmidiDecoderPlugin.cxx index 832cabe76..1358c20d3 100644 --- a/src/decoder/WildmidiDecoderPlugin.cxx +++ b/src/decoder/WildmidiDecoderPlugin.cxx @@ -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; diff --git a/src/decoder/sidplay_decoder_plugin.cxx b/src/decoder/sidplay_decoder_plugin.cxx index d63dca6af..4e26efecb 100644 --- a/src/decoder/sidplay_decoder_plugin.cxx +++ b/src/decoder/sidplay_decoder_plugin.cxx @@ -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; } |