diff options
Diffstat (limited to 'src/DecoderList.cxx')
-rw-r--r-- | src/DecoderList.cxx | 69 |
1 files changed, 9 insertions, 60 deletions
diff --git a/src/DecoderList.cxx b/src/DecoderList.cxx index 834178260..8c688fa9b 100644 --- a/src/DecoderList.cxx +++ b/src/DecoderList.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -118,65 +118,6 @@ static constexpr unsigned num_decoder_plugins = /** which plugins have been initialized successfully? */ bool decoder_plugins_enabled[num_decoder_plugins]; -static unsigned -decoder_plugin_index(const struct DecoderPlugin *plugin) -{ - unsigned i = 0; - - while (decoder_plugins[i] != plugin) - ++i; - - return i; -} - -static unsigned -decoder_plugin_next_index(const struct DecoderPlugin *plugin) -{ - return plugin == 0 - ? 0 /* start with first plugin */ - : decoder_plugin_index(plugin) + 1; -} - -const struct DecoderPlugin * -decoder_plugin_from_suffix(const char *suffix, - const struct DecoderPlugin *plugin) -{ - if (suffix == nullptr) - return nullptr; - - for (unsigned i = decoder_plugin_next_index(plugin); - decoder_plugins[i] != nullptr; ++i) { - plugin = decoder_plugins[i]; - if (decoder_plugins_enabled[i] && - plugin->SupportsSuffix(suffix)) - return plugin; - } - - return nullptr; -} - -const struct DecoderPlugin * -decoder_plugin_from_mime_type(const char *mimeType, unsigned int next) -{ - static unsigned i = num_decoder_plugins; - - if (mimeType == nullptr) - return nullptr; - - if (!next) - i = 0; - for (; decoder_plugins[i] != nullptr; ++i) { - const struct DecoderPlugin *plugin = decoder_plugins[i]; - if (decoder_plugins_enabled[i] && - plugin->SupportsMimeType(mimeType)) { - ++i; - return plugin; - } - } - - return nullptr; -} - const struct DecoderPlugin * decoder_plugin_from_name(const char *name) { @@ -235,3 +176,11 @@ void decoder_plugin_deinit_all(void) plugin.Finish(); }); } + +bool +decoder_plugins_supports_suffix(const char *suffix) +{ + return decoder_plugins_try([suffix](const DecoderPlugin &plugin){ + return plugin.SupportsSuffix(suffix); + }); +} |