From 58dbe4bb5d974c34335d6906a9ce930f07cd1db4 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Thu, 28 Oct 2004 05:14:55 +0000 Subject: merge shank-rewrite-config changes git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/audioOutput.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'src/audioOutput.c') diff --git a/src/audioOutput.c b/src/audioOutput.c index d85b9d978..0175ed04f 100644 --- a/src/audioOutput.c +++ b/src/audioOutput.c @@ -1,6 +1,12 @@ -#include +#include "audioOutput.h" -#include +#include "list.h" +#include "log.h" + +#include + +#define AUDIO_OUTPUT_TYPE "type" +#define AUDIO_OUTPUT_NAME "name" static List * audioOutputPluginList; @@ -21,13 +27,32 @@ void finishAudioOutputPlugins() { freeList(audioOutputPluginList); } -AudioOutput * newAudioOutput(char * name) { +#define getBlockParam(name, str) { \ + BlockParam * bp; \ + bp = getBlockParam(param, name); \ + if(bp == NULL) { \ + ERROR("couldn't find parameter \"%s\" in audio output " \ + "definition begining at %i\n", \ + name, param->line); \ + exit(EXIT_FAILURE); \ + } \ + str = bp->value; \ +} + +AudioOutput * newAudioOutput(ConfigParam * param) { AudioOutput * ret = NULL; void * data = NULL; + char * name = NULL; + char * type = NULL; + + getBlockParam(AUDIO_OUTPUT_NAME, name); + getBlockParam(AUDIO_OUTPUT_TYPE, type); - if(findInList(audioOutputPluginList, name, &data)) { + 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; @@ -35,11 +60,16 @@ AudioOutput * newAudioOutput(char * name) { ret->sendMetdataFunc = plugin->sendMetdataFunc; ret->open = 0; - if(plugin->initDriverFunc(ret) != 0) { + if(plugin->initDriverFunc(ret, param) != 0) { free(ret); ret = NULL; } } + else { + ERROR("couldn't find audio output plugin for type \"%s\" at " + "line %i", type, param->line); + exit(EXIT_FAILURE); + } return ret; } -- cgit v1.2.3