diff options
Diffstat (limited to 'src/decoder/decoder_list.c')
-rw-r--r-- | src/decoder/decoder_list.c | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/src/decoder/decoder_list.c b/src/decoder/decoder_list.c index d9437e86..ee65658d 100644 --- a/src/decoder/decoder_list.c +++ b/src/decoder/decoder_list.c @@ -31,12 +31,12 @@ extern const struct decoder_plugin libav_decoder_plugin; const struct decoder_plugin *const decoder_plugins[] = { - &libav_decoder_plugin, - NULL + &libav_decoder_plugin, + NULL }; enum { - num_decoder_plugins = G_N_ELEMENTS(decoder_plugins) - 1, + num_decoder_plugins = G_N_ELEMENTS(decoder_plugins) - 1, }; /** which plugins have been initialized successfully? */ @@ -45,70 +45,70 @@ bool decoder_plugins_enabled[num_decoder_plugins]; static unsigned decoder_plugin_index(const struct decoder_plugin *plugin) { - unsigned i = 0; + unsigned i = 0; - while (decoder_plugins[i] != plugin) - ++i; + while (decoder_plugins[i] != plugin) + ++i; - return i; + return i; } static unsigned decoder_plugin_next_index(const struct decoder_plugin *plugin) { - return plugin == 0 - ? 0 /* start with first plugin */ - : decoder_plugin_index(plugin) + 1; + return plugin == 0 + ? 0 /* start with first plugin */ + : decoder_plugin_index(plugin) + 1; } const struct decoder_plugin * decoder_plugin_from_suffix(const char *suffix, - const struct decoder_plugin *plugin) + const struct decoder_plugin *plugin) { - if (suffix == NULL) - return NULL; - - for (unsigned i = decoder_plugin_next_index(plugin); - decoder_plugins[i] != NULL; ++i) { - plugin = decoder_plugins[i]; - if (decoder_plugins_enabled[i] && - decoder_plugin_supports_suffix(plugin, suffix)) - return plugin; - } - - return NULL; + if (suffix == NULL) + return NULL; + + for (unsigned i = decoder_plugin_next_index(plugin); + decoder_plugins[i] != NULL; ++i) { + plugin = decoder_plugins[i]; + if (decoder_plugins_enabled[i] && + decoder_plugin_supports_suffix(plugin, suffix)) + return plugin; + } + + return NULL; } const struct decoder_plugin * decoder_plugin_from_mime_type(const char *mimeType, unsigned int next) { - static unsigned i = num_decoder_plugins; - - if (mimeType == NULL) - return NULL; - - if (!next) - i = 0; - for (; decoder_plugins[i] != NULL; ++i) { - const struct decoder_plugin *plugin = decoder_plugins[i]; - if (decoder_plugins_enabled[i] && - decoder_plugin_supports_mime_type(plugin, mimeType)) { - ++i; - return plugin; - } - } - - return NULL; + static unsigned i = num_decoder_plugins; + + if (mimeType == NULL) + return NULL; + + if (!next) + i = 0; + for (; decoder_plugins[i] != NULL; ++i) { + const struct decoder_plugin *plugin = decoder_plugins[i]; + if (decoder_plugins_enabled[i] && + decoder_plugin_supports_mime_type(plugin, mimeType)) { + ++i; + return plugin; + } + } + + return NULL; } const struct decoder_plugin * decoder_plugin_from_name(const char *name) { - decoder_plugins_for_each_enabled(plugin) - if (strcmp(plugin->name, name) == 0) - return plugin; + decoder_plugins_for_each_enabled(plugin) + if (strcmp(plugin->name, name) == 0) + return plugin; - return NULL; + return NULL; } /** @@ -120,40 +120,40 @@ decoder_plugin_from_name(const char *name) static const struct config_param * decoder_plugin_config(const char *plugin_name) { - const struct config_param *param = NULL; + 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) - MPD_ERROR("decoder configuration without 'plugin' name in line %d", - param->line); + while ((param = config_get_next_param(CONF_DECODER, param)) != NULL) { + const char *name = + config_get_block_string(param, "plugin", NULL); + if (name == NULL) + MPD_ERROR("decoder configuration without 'plugin' name in line %d", + param->line); - if (strcmp(name, plugin_name) == 0) - return param; - } + if (strcmp(name, plugin_name) == 0) + return param; + } - return NULL; + return NULL; } void decoder_plugin_init_all(void) { - 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)) - /* the plugin is disabled in mpd.conf */ - continue; - - if (decoder_plugin_init(plugin, param)) - decoder_plugins_enabled[i] = true; - } + 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)) + /* the plugin is disabled in mpd.conf */ + continue; + + if (decoder_plugin_init(plugin, param)) + decoder_plugins_enabled[i] = true; + } } void decoder_plugin_deinit_all(void) { - decoder_plugins_for_each_enabled(plugin) - decoder_plugin_finish(plugin); + decoder_plugins_for_each_enabled(plugin) + decoder_plugin_finish(plugin); } |