diff options
author | Max Kellermann <max@duempel.org> | 2012-06-12 23:22:03 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-06-12 23:22:03 +0200 |
commit | 4eb57e1e9a1718ce93eced6bd4fb06d8abb26477 (patch) | |
tree | 2355c6d77273cf614822f5a144005ab1d353863b /src/playlist | |
parent | d662c4c0cc089a6a493a7463e440f0f7e7959b48 (diff) | |
parent | 1d52e2cc7727d93e65d557c322b5dd7dc149651c (diff) | |
download | mpd-4eb57e1e9a1718ce93eced6bd4fb06d8abb26477.tar.gz mpd-4eb57e1e9a1718ce93eced6bd4fb06d8abb26477.tar.xz mpd-4eb57e1e9a1718ce93eced6bd4fb06d8abb26477.zip |
Merge branch 'v0.16.x'
Conflicts:
src/cmdline.c
src/decoder/wildmidi_decoder_plugin.c
src/gcc.h
src/glib_compat.h
src/input_stream.c
src/output_list.c
src/output_thread.c
valgrind.suppressions
Diffstat (limited to '')
-rw-r--r-- | src/playlist_list.c | 31 | ||||
-rw-r--r-- | src/playlist_list.h | 8 | ||||
-rw-r--r-- | src/playlist_save.c | 1 |
3 files changed, 22 insertions, 18 deletions
diff --git a/src/playlist_list.c b/src/playlist_list.c index 64f03d46d..3d4edb9e1 100644 --- a/src/playlist_list.c +++ b/src/playlist_list.c @@ -42,7 +42,7 @@ #include <string.h> #include <stdio.h> -static const struct playlist_plugin *const playlist_plugins[] = { +const struct playlist_plugin *const playlist_plugins[] = { &extm3u_playlist_plugin, &m3u_playlist_plugin, &xspf_playlist_plugin, @@ -66,6 +66,10 @@ static const struct playlist_plugin *const playlist_plugins[] = { /** which plugins have been initialized successfully? */ static bool playlist_plugins_enabled[G_N_ELEMENTS(playlist_plugins)]; +#define playlist_plugins_for_each_enabled(plugin) \ + playlist_plugins_for_each(plugin) \ + if (playlist_plugins_enabled[playlist_plugin_iterator - playlist_plugins]) + /** * Find the "playlist" configuration block for the specified plugin. * @@ -113,9 +117,8 @@ playlist_list_global_init(void) void playlist_list_global_finish(void) { - for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) - if (playlist_plugins_enabled[i]) - playlist_plugin_finish(playlist_plugins[i]); + playlist_plugins_for_each_enabled(plugin) + playlist_plugin_finish(plugin); } static struct playlist_provider * @@ -209,11 +212,8 @@ playlist_list_open_stream_mime2(struct input_stream *is, const char *mime) assert(is != NULL); assert(mime != NULL); - for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) { - const struct playlist_plugin *plugin = playlist_plugins[i]; - - if (playlist_plugins_enabled[i] && - plugin->open_stream != NULL && + playlist_plugins_for_each_enabled(plugin) { + if (plugin->open_stream != NULL && plugin->mime_types != NULL && string_array_contains(plugin->mime_types, mime)) { /* rewind the stream, so each plugin gets a @@ -257,11 +257,8 @@ playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix) assert(is != NULL); assert(suffix != NULL); - for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) { - const struct playlist_plugin *plugin = playlist_plugins[i]; - - if (playlist_plugins_enabled[i] && - plugin->open_stream != NULL && + playlist_plugins_for_each_enabled(plugin) { + if (plugin->open_stream != NULL && plugin->suffixes != NULL && string_array_contains(plugin->suffixes, suffix)) { /* rewind the stream, so each plugin gets a @@ -306,10 +303,8 @@ playlist_suffix_supported(const char *suffix) { assert(suffix != NULL); - for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) { - const struct playlist_plugin *plugin = playlist_plugins[i]; - - if (playlist_plugins_enabled[i] && plugin->suffixes != NULL && + playlist_plugins_for_each_enabled(plugin) { + if (plugin->suffixes != NULL && string_array_contains(plugin->suffixes, suffix)) return true; } diff --git a/src/playlist_list.h b/src/playlist_list.h index 4a2485303..c3967d5ae 100644 --- a/src/playlist_list.h +++ b/src/playlist_list.h @@ -27,6 +27,14 @@ struct playlist_provider; struct input_stream; +extern const struct playlist_plugin *const playlist_plugins[]; + +#define playlist_plugins_for_each(plugin) \ + for (const struct playlist_plugin *plugin, \ + *const*playlist_plugin_iterator = &playlist_plugins[0]; \ + (plugin = *playlist_plugin_iterator) != NULL; \ + ++playlist_plugin_iterator) + /** * Initializes all playlist plugins. */ diff --git a/src/playlist_save.c b/src/playlist_save.c index 6571e286c..122eca332 100644 --- a/src/playlist_save.c +++ b/src/playlist_save.c @@ -28,6 +28,7 @@ #include "uri.h" #include "database.h" #include "idle.h" +#include "glib_compat.h" #include <glib.h> |