aboutsummaryrefslogtreecommitdiffstats
path: root/src/encoder
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/encoder_list.c18
-rw-r--r--src/encoder_list.h13
2 files changed, 12 insertions, 19 deletions
diff --git a/src/encoder_list.c b/src/encoder_list.c
index d98e617b4..2326c1099 100644
--- a/src/encoder_list.c
+++ b/src/encoder_list.c
@@ -30,7 +30,7 @@ extern const struct encoder_plugin twolame_encoder_plugin;
extern const struct encoder_plugin wave_encoder_plugin;
extern const struct encoder_plugin flac_encoder_plugin;
-static const struct encoder_plugin *encoder_plugins[] = {
+const struct encoder_plugin *const encoder_plugins[] = {
&null_encoder_plugin,
#ifdef ENABLE_VORBIS_ENCODER
&vorbis_encoder_plugin,
@@ -53,19 +53,9 @@ static const struct encoder_plugin *encoder_plugins[] = {
const struct encoder_plugin *
encoder_plugin_get(const char *name)
{
- for (unsigned i = 0; encoder_plugins[i] != NULL; ++i)
- if (strcmp(encoder_plugins[i]->name, name) == 0)
- return encoder_plugins[i];
+ encoder_plugins_for_each(plugin)
+ if (strcmp(plugin->name, name) == 0)
+ return plugin;
return NULL;
}
-
-void
-encoder_plugin_print_all_types(FILE * fp)
-{
- for (unsigned i = 0; encoder_plugins[i] != NULL; ++i)
- fprintf(fp, "%s ", encoder_plugins[i]->name);
-
- fprintf(fp, "\n");
- fflush(fp);
-}
diff --git a/src/encoder_list.h b/src/encoder_list.h
index 6316d5d2f..fb1c9bf9c 100644
--- a/src/encoder_list.h
+++ b/src/encoder_list.h
@@ -20,10 +20,16 @@
#ifndef MPD_ENCODER_LIST_H
#define MPD_ENCODER_LIST_H
-#include <stdio.h>
-
struct encoder_plugin;
+extern const struct encoder_plugin *const encoder_plugins[];
+
+#define encoder_plugins_for_each(plugin) \
+ for (const struct encoder_plugin *plugin, \
+ *const*encoder_plugin_iterator = &encoder_plugins[0]; \
+ (plugin = *encoder_plugin_iterator) != NULL; \
+ ++encoder_plugin_iterator)
+
/**
* Looks up an encoder plugin by its name.
*
@@ -34,7 +40,4 @@ struct encoder_plugin;
const struct encoder_plugin *
encoder_plugin_get(const char *name);
-void
-encoder_plugin_print_all_types(FILE * fp);
-
#endif