aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutput.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2005-03-12 03:10:09 +0000
committerWarren Dukes <warren.dukes@gmail.com>2005-03-12 03:10:09 +0000
commit8583a3bc4e9af2a1be06c82422a7cac1470341ce (patch)
tree4befe14e73239f6bcabc6046499bd0e4a99ebe88 /src/audioOutput.c
parent18651935754dbf8972cd8188c2ec5b05ded60299 (diff)
downloadmpd-8583a3bc4e9af2a1be06c82422a7cac1470341ce.tar.gz
mpd-8583a3bc4e9af2a1be06c82422a7cac1470341ce.tar.xz
mpd-8583a3bc4e9af2a1be06c82422a7cac1470341ce.zip
if no audioOutput specified, we no attempt to detect if there exists a usable oss or alsa device
git-svn-id: https://svn.musicpd.org/mpd/trunk@3057 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutput.c')
-rw-r--r--src/audioOutput.c108
1 files changed, 70 insertions, 38 deletions
diff --git a/src/audioOutput.c b/src/audioOutput.c
index 1186dbe0d..632d1b8dc 100644
--- a/src/audioOutput.c
+++ b/src/audioOutput.c
@@ -48,55 +48,87 @@ AudioOutput * newAudioOutput(ConfigParam * param) {
char * name = NULL;
char * format = NULL;
char * type = NULL;
- BlockParam * bp;
-
- getBlockParam(AUDIO_OUTPUT_NAME, name, 1);
- getBlockParam(AUDIO_OUTPUT_TYPE, type, 1);
-
- if(findInList(audioOutputPluginList, type, &data)) {
- AudioOutputPlugin * plugin = (AudioOutputPlugin *) data;
- ret = malloc(sizeof(AudioOutput));
- ret->name = strdup(name);
- ret->type = strdup(type);
- ret->finishDriverFunc = plugin->finishDriverFunc;
- ret->openDeviceFunc = plugin->openDeviceFunc;
- ret->playFunc = plugin->playFunc;
- ret->dropBufferedAudioFunc = plugin->dropBufferedAudioFunc;
- ret->closeDeviceFunc = plugin->closeDeviceFunc;
- ret->sendMetdataFunc = plugin->sendMetdataFunc;
- ret->open = 0;
-
- ret->convertAudioFormat = 0;
- ret->sameInAndOutFormats = 0;
- ret->convBuffer = NULL;
- ret->convBufferLen = 0;
-
- memset(&ret->inAudioFormat, 0, sizeof(AudioFormat));
- memset(&ret->outAudioFormat, 0, sizeof(AudioFormat));
- memset(&ret->reqAudioFormat, 0, sizeof(AudioFormat));
-
- getBlockParam(AUDIO_OUTPUT_FORMAT, format, 0);
+ BlockParam * bp = NULL;
+ AudioOutputPlugin * plugin = NULL;
+
+ if(param) {
+ getBlockParam(AUDIO_OUTPUT_NAME, name, 1);
+ getBlockParam(AUDIO_OUTPUT_TYPE, type, 1);
+
+ if(!findInList(audioOutputPluginList, type, &data)) {
+ ERROR("couldn't find audio output plugin for type "
+ "\"%s\" at line %i\n", type,
+ param->line);
+ exit(EXIT_FAILURE);
+ }
+ plugin = (AudioOutputPlugin *) data;
+
if(format) {
ret->convertAudioFormat = 1;
if(0 != parseAudioConfig(&ret->reqAudioFormat, format))
{
- ERROR("error parsing format at line %i\n",
+ ERROR("error parsing format at line %i\n",
bp->line);
- exit(EXIT_FAILURE);
- }
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+ else {
+ ListNode * node = audioOutputPluginList->firstNode;
+
+ WARNING("No \"%s\" defined in config file\n",
+ CONF_AUDIO_OUTPUT);
+ WARNING("Attempt to detect audio output device\n");
+
+ while(node) {
+ plugin = (AudioOutputPlugin *) node->data;
+ if(plugin->testDefaultDeviceFunc) {
+ WARNING("Attempting to detect a %s audio "
+ "device\n", plugin->name);
+ if(plugin->testDefaultDeviceFunc() == 0) {
+ WARNING("Successfully detected a %s "
+ "audio device\n",
+ plugin->name);
+ break;
+ }
+ }
+ node = node->nextNode;
}
- if(plugin->initDriverFunc(ret, param) != 0) {
- free(ret);
- ret = NULL;
+ if(!node) {
+ WARNING("Unable to detect an audio device\n");
+ return NULL;
}
+
+ name = "default detected output";
+ type = plugin->name;
}
- else {
- ERROR("couldn't find audio output plugin for type \"%s\" at "
- "line %i\n", type, param->line);
- exit(EXIT_FAILURE);
+
+ ret = malloc(sizeof(AudioOutput));
+ ret->name = strdup(name);
+ ret->type = strdup(type);
+ ret->finishDriverFunc = plugin->finishDriverFunc;
+ ret->openDeviceFunc = plugin->openDeviceFunc;
+ ret->playFunc = plugin->playFunc;
+ ret->dropBufferedAudioFunc = plugin->dropBufferedAudioFunc;
+ ret->closeDeviceFunc = plugin->closeDeviceFunc;
+ ret->sendMetdataFunc = plugin->sendMetdataFunc;
+ ret->open = 0;
+
+ ret->convertAudioFormat = 0;
+ ret->sameInAndOutFormats = 0;
+ ret->convBuffer = NULL;
+ ret->convBufferLen = 0;
+
+ memset(&ret->inAudioFormat, 0, sizeof(AudioFormat));
+ memset(&ret->outAudioFormat, 0, sizeof(AudioFormat));
+ memset(&ret->reqAudioFormat, 0, sizeof(AudioFormat));
+
+ if(plugin->initDriverFunc(ret, param) != 0) {
+ free(ret);
+ ret = NULL;
}
return ret;