aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-06-12 23:22:03 +0200
committerMax Kellermann <max@duempel.org>2012-06-12 23:22:03 +0200
commit4eb57e1e9a1718ce93eced6bd4fb06d8abb26477 (patch)
tree2355c6d77273cf614822f5a144005ab1d353863b /src/decoder
parentd662c4c0cc089a6a493a7463e440f0f7e7959b48 (diff)
parent1d52e2cc7727d93e65d557c322b5dd7dc149651c (diff)
downloadmpd-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/decoder/wildmidi_decoder_plugin.c1
-rw-r--r--src/decoder_list.c15
-rw-r--r--src/decoder_list.h10
-rw-r--r--src/decoder_print.c5
4 files changed, 17 insertions, 14 deletions
diff --git a/src/decoder/wildmidi_decoder_plugin.c b/src/decoder/wildmidi_decoder_plugin.c
index a2224940d..2cdb30a9c 100644
--- a/src/decoder/wildmidi_decoder_plugin.c
+++ b/src/decoder/wildmidi_decoder_plugin.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "decoder_api.h"
#include "tag_handler.h"
+#include "glib_compat.h"
#include <glib.h>
diff --git a/src/decoder_list.c b/src/decoder_list.c
index 2029b3e62..e9e29c691 100644
--- a/src/decoder_list.c
+++ b/src/decoder_list.c
@@ -178,12 +178,9 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
const struct decoder_plugin *
decoder_plugin_from_name(const char *name)
{
- for (unsigned i = 0; decoder_plugins[i] != NULL; ++i) {
- const struct decoder_plugin *plugin = decoder_plugins[i];
- if (decoder_plugins_enabled[i] &&
- strcmp(plugin->name, name) == 0)
+ decoder_plugins_for_each_enabled(plugin)
+ if (strcmp(plugin->name, name) == 0)
return plugin;
- }
return NULL;
}
@@ -231,10 +228,6 @@ void decoder_plugin_init_all(void)
void decoder_plugin_deinit_all(void)
{
- for (unsigned i = 0; decoder_plugins[i] != NULL; ++i) {
- const struct decoder_plugin *plugin = decoder_plugins[i];
-
- if (decoder_plugins_enabled[i])
- decoder_plugin_finish(plugin);
- }
+ decoder_plugins_for_each_enabled(plugin)
+ decoder_plugin_finish(plugin);
}
diff --git a/src/decoder_list.h b/src/decoder_list.h
index d259cb195..d0a6ade7e 100644
--- a/src/decoder_list.h
+++ b/src/decoder_list.h
@@ -27,6 +27,16 @@ struct decoder_plugin;
extern const struct decoder_plugin *const decoder_plugins[];
extern bool decoder_plugins_enabled[];
+#define decoder_plugins_for_each(plugin) \
+ for (const struct decoder_plugin *plugin, \
+ *const*decoder_plugin_iterator = &decoder_plugins[0]; \
+ (plugin = *decoder_plugin_iterator) != NULL; \
+ ++decoder_plugin_iterator)
+
+#define decoder_plugins_for_each_enabled(plugin) \
+ decoder_plugins_for_each(plugin) \
+ if (decoder_plugins_enabled[decoder_plugin_iterator - decoder_plugins])
+
/* interface for using plugins */
/**
diff --git a/src/decoder_print.c b/src/decoder_print.c
index 72c40ac75..e14477ed8 100644
--- a/src/decoder_print.c
+++ b/src/decoder_print.c
@@ -48,7 +48,6 @@ decoder_plugin_print(struct client *client,
void
decoder_list_print(struct client *client)
{
- for (unsigned i = 0; decoder_plugins[i] != NULL; ++i)
- if (decoder_plugins_enabled[i])
- decoder_plugin_print(client, decoder_plugins[i]);
+ decoder_plugins_for_each_enabled(plugin)
+ decoder_plugin_print(client, plugin);
}