diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-10-28 05:14:55 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-10-28 05:14:55 +0000 |
commit | 58dbe4bb5d974c34335d6906a9ce930f07cd1db4 (patch) | |
tree | 9a6aee08b21100cb74e809f0620d81466f6067df /src/audioOutput.c | |
parent | 8f40569aeeafe4a36e3d719c1df97de42606ea76 (diff) | |
download | mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.gz mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.xz mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.zip |
merge shank-rewrite-config changes
git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/audioOutput.c | 40 |
1 files changed, 35 insertions, 5 deletions
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 <audioOutput.h> +#include "audioOutput.h" -#include <list.h> +#include "list.h" +#include "log.h" + +#include <string.h> + +#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; } |