encoder_list: add macro _for_each()
This commit is contained in:
parent
90709a6de4
commit
edbfa46cbc
@ -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 wave_encoder_plugin;
|
||||||
extern const struct encoder_plugin flac_encoder_plugin;
|
extern const struct encoder_plugin flac_encoder_plugin;
|
||||||
|
|
||||||
static const struct encoder_plugin *const encoder_plugins[] = {
|
const struct encoder_plugin *const encoder_plugins[] = {
|
||||||
&null_encoder_plugin,
|
&null_encoder_plugin,
|
||||||
#ifdef ENABLE_VORBIS_ENCODER
|
#ifdef ENABLE_VORBIS_ENCODER
|
||||||
&vorbis_encoder_plugin,
|
&vorbis_encoder_plugin,
|
||||||
@ -53,9 +53,9 @@ static const struct encoder_plugin *const encoder_plugins[] = {
|
|||||||
const struct encoder_plugin *
|
const struct encoder_plugin *
|
||||||
encoder_plugin_get(const char *name)
|
encoder_plugin_get(const char *name)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; encoder_plugins[i] != NULL; ++i)
|
encoder_plugins_for_each(plugin)
|
||||||
if (strcmp(encoder_plugins[i]->name, name) == 0)
|
if (strcmp(plugin->name, name) == 0)
|
||||||
return encoder_plugins[i];
|
return plugin;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -63,8 +63,8 @@ encoder_plugin_get(const char *name)
|
|||||||
void
|
void
|
||||||
encoder_plugin_print_all_types(FILE * fp)
|
encoder_plugin_print_all_types(FILE * fp)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; encoder_plugins[i] != NULL; ++i)
|
encoder_plugins_for_each(plugin)
|
||||||
fprintf(fp, "%s ", encoder_plugins[i]->name);
|
fprintf(fp, "%s ", plugin->name);
|
||||||
|
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
|
@ -24,6 +24,14 @@
|
|||||||
|
|
||||||
struct encoder_plugin;
|
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.
|
* Looks up an encoder plugin by its name.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user