output_list: declare variables inside _plugins_for_each()

Don't require the caller to provide them.
This commit is contained in:
Max Kellermann 2012-06-12 20:29:47 +02:00
parent ed915fed92
commit 992c2fa2d4
3 changed files with 7 additions and 14 deletions

View File

@ -49,12 +49,9 @@
static const struct audio_output_plugin * static const struct audio_output_plugin *
audio_output_detect(GError **error) audio_output_detect(GError **error)
{ {
const struct audio_output_plugin *plugin;
unsigned i;
g_warning("Attempt to detect audio output device"); g_warning("Attempt to detect audio output device");
audio_output_plugins_for_each(plugin, i) { audio_output_plugins_for_each(plugin) {
if (plugin->test_default_device == NULL) if (plugin->test_default_device == NULL)
continue; continue;

View File

@ -95,10 +95,7 @@ const struct audio_output_plugin *const audio_output_plugins[] = {
const struct audio_output_plugin * const struct audio_output_plugin *
audio_output_plugin_get(const char *name) audio_output_plugin_get(const char *name)
{ {
unsigned int i; audio_output_plugins_for_each(plugin)
const struct audio_output_plugin *plugin;
audio_output_plugins_for_each(plugin, i)
if (strcmp(plugin->name, name) == 0) if (strcmp(plugin->name, name) == 0)
return plugin; return plugin;
@ -107,10 +104,7 @@ audio_output_plugin_get(const char *name)
void audio_output_plugin_print_all_types(FILE * fp) void audio_output_plugin_print_all_types(FILE * fp)
{ {
unsigned i; audio_output_plugins_for_each(plugin)
const struct audio_output_plugin *plugin;
audio_output_plugins_for_each(plugin, i)
fprintf(fp, "%s ", plugin->name); fprintf(fp, "%s ", plugin->name);
fprintf(fp, "\n"); fprintf(fp, "\n");

View File

@ -29,7 +29,9 @@ audio_output_plugin_get(const char *name);
void audio_output_plugin_print_all_types(FILE * fp); void audio_output_plugin_print_all_types(FILE * fp);
#define audio_output_plugins_for_each(plugin, i) \ #define audio_output_plugins_for_each(plugin) \
for (i = 0; (plugin = audio_output_plugins[i]) != NULL; ++i) for (const struct audio_output_plugin *plugin, \
*const*output_plugin_iterator = &audio_output_plugins[0]; \
(plugin = *output_plugin_iterator) != NULL; ++output_plugin_iterator)
#endif #endif