diff options
author | Max Kellermann <max@duempel.org> | 2009-02-15 18:35:19 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-15 18:35:19 +0100 |
commit | 6cfacc778c11565adc5af75cfa4579c1b6925c93 (patch) | |
tree | 33ff5133731d4164e3c64dc82bb34989d3dab6f2 | |
parent | dec5d48f80428575c7a1b9eeba961b0055156500 (diff) | |
download | mpd-6cfacc778c11565adc5af75cfa4579c1b6925c93.tar.gz mpd-6cfacc778c11565adc5af75cfa4579c1b6925c93.tar.xz mpd-6cfacc778c11565adc5af75cfa4579c1b6925c93.zip |
decoder_list: added configuration block "decoder"
The "decoder" configuration block may contain the configuration of one
decoder plugin.
-rw-r--r-- | src/conf.c | 1 | ||||
-rw-r--r-- | src/conf.h | 1 | ||||
-rw-r--r-- | src/decoder_list.c | 30 |
3 files changed, 31 insertions, 1 deletions
diff --git a/src/conf.c b/src/conf.c index 7560c02ba..3f58d61aa 100644 --- a/src/conf.c +++ b/src/conf.c @@ -210,6 +210,7 @@ void config_global_init(void) registerConfigParam(CONF_ID3V1_ENCODING, 0, 0); registerConfigParam(CONF_METADATA_TO_USE, 0, 0); registerConfigParam(CONF_SAVE_ABSOLUTE_PATHS, 0, 0); + registerConfigParam(CONF_DECODER, true, true); registerConfigParam(CONF_GAPLESS_MP3_PLAYBACK, 0, 0); } diff --git a/src/conf.h b/src/conf.h index 5e191815f..95bdb4d02 100644 --- a/src/conf.h +++ b/src/conf.h @@ -64,6 +64,7 @@ #define CONF_ID3V1_ENCODING "id3v1_encoding" #define CONF_METADATA_TO_USE "metadata_to_use" #define CONF_SAVE_ABSOLUTE_PATHS "save_absolute_paths_in_playlists" +#define CONF_DECODER "decoder" #define CONF_GAPLESS_MP3_PLAYBACK "gapless_mp3_playback" #define CONF_BOOL_UNSET -1 diff --git a/src/decoder_list.c b/src/decoder_list.c index f0cf8625b..a644a6370 100644 --- a/src/decoder_list.c +++ b/src/decoder_list.c @@ -20,6 +20,7 @@ #include "decoder_plugin.h" #include "utils.h" #include "config.h" +#include "conf.h" #include <glib.h> @@ -185,12 +186,39 @@ void decoder_plugin_print_all_decoders(FILE * fp) fflush(fp); } +/** + * Find the "decoder" configuration block for the specified plugin. + * + * @param plugin_name the name of the decoder plugin + * @return the configuration block, or NULL if none was configured + */ +static const struct config_param * +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); + if (name == NULL) + g_error("decoder configuration without 'plugin' name in line %d", + param->line); + + if (strcmp(name, plugin_name) == 0) + return param; + } + + return NULL; +} + void decoder_plugin_init_all(void) { for (unsigned i = 0; i < num_decoder_plugins; ++i) { const struct decoder_plugin *plugin = decoder_plugins[i]; + const struct config_param *param = + decoder_plugin_config(plugin->name); - if (decoder_plugin_init(plugin, NULL)) + if (decoder_plugin_init(plugin, param)) decoder_plugins_enabled[i] = true; } } |