From cb942eeb45e15d6b471625629dcb324e625cfac7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 1 Mar 2009 13:31:32 +0100 Subject: output_init: moved code to audio_output_detect() --- src/output_init.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/output_init.c b/src/output_init.c index a007dbd1b..4c052d943 100644 --- a/src/output_init.c +++ b/src/output_init.c @@ -41,6 +41,27 @@ if(bp) str = bp->value; \ } +static const struct audio_output_plugin * +audio_output_detect(void) +{ + const struct audio_output_plugin *plugin; + unsigned i; + + g_warning("Attempt to detect audio output device"); + + audio_output_plugins_for_each(plugin, i) { + if (plugin->test_default_device == NULL) + continue; + + g_warning("Attempting to detect a %s audio device", + plugin->name); + if (ao_plugin_test_default_device(plugin)) + return plugin; + } + + return NULL; +} + bool audio_output_init(struct audio_output *ao, const struct config_param *param) { @@ -63,29 +84,18 @@ audio_output_init(struct audio_output *ao, const struct config_param *param) "\"%s\" at line %i\n", type, param->line); } } else { - unsigned i; - g_warning("No \"%s\" defined in config file\n", CONF_AUDIO_OUTPUT); - g_warning("Attempt to detect audio output device\n"); - - audio_output_plugins_for_each(plugin, i) { - if (plugin->test_default_device) { - g_warning("Attempting to detect a %s audio " - "device\n", plugin->name); - if (ao_plugin_test_default_device(plugin)) { - g_warning("Successfully detected a %s " - "audio device\n", plugin->name); - break; - } - } - } + plugin = audio_output_detect(); if (plugin == NULL) { - g_warning("Unable to detect an audio device\n"); + g_warning("Unable to detect an audio device"); return false; } + g_message("Successfully detected a %s audio device", + plugin->name); + name = "default detected output"; } -- cgit v1.2.3