aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutput.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-08 11:43:13 +0200
committerMax Kellermann <max@duempel.org>2008-09-08 11:43:13 +0200
commitbe046b25a4e2583f63d6b3da680e6451957750e4 (patch)
treef295ed51a8e2ab4f7eb504ee2d2ea2e471ad7e2c /src/audioOutput.c
parenta0103dd05ce4f42f3be2ff951ea44d6e76dadc2f (diff)
downloadmpd-be046b25a4e2583f63d6b3da680e6451957750e4.tar.gz
mpd-be046b25a4e2583f63d6b3da680e6451957750e4.tar.xz
mpd-be046b25a4e2583f63d6b3da680e6451957750e4.zip
output: static audio_output_plugin list as array
Instead of having to register each output plugin, store them statically in an array. This eliminates the need for the List library here, and saves some small allocations during startup.
Diffstat (limited to 'src/audioOutput.c')
-rw-r--r--src/audioOutput.c55
1 files changed, 11 insertions, 44 deletions
diff --git a/src/audioOutput.c b/src/audioOutput.c
index 0991d55d0..0a3e9abd8 100644
--- a/src/audioOutput.c
+++ b/src/audioOutput.c
@@ -18,8 +18,8 @@
#include "audioOutput.h"
#include "output_api.h"
+#include "output_list.h"
-#include "list.h"
#include "log.h"
#include "pcm_utils.h"
#include "utils.h"
@@ -30,33 +30,6 @@
#define AUDIO_OUTPUT_NAME "name"
#define AUDIO_OUTPUT_FORMAT "format"
-static List *audioOutputPluginList;
-
-void loadAudioOutputPlugin(struct audio_output_plugin *audioOutputPlugin)
-{
- if (!audioOutputPlugin->name)
- return;
- insertInList(audioOutputPluginList, audioOutputPlugin->name,
- audioOutputPlugin);
-}
-
-void unloadAudioOutputPlugin(struct audio_output_plugin *audioOutputPlugin)
-{
- if (!audioOutputPlugin->name)
- return;
- deleteFromList(audioOutputPluginList, audioOutputPlugin->name);
-}
-
-void initAudioOutputPlugins(void)
-{
- audioOutputPluginList = makeList(NULL, 0);
-}
-
-void finishAudioOutputPlugins(void)
-{
- freeList(audioOutputPluginList);
-}
-
#define getBlockParam(name, str, force) { \
bp = getBlockParam(param, name); \
if(force && bp == NULL) { \
@@ -69,11 +42,10 @@ void finishAudioOutputPlugins(void)
int initAudioOutput(struct audio_output *ao, ConfigParam * param)
{
- void *data = NULL;
const char *name = NULL;
char *format = NULL;
BlockParam *bp = NULL;
- struct audio_output_plugin *plugin = NULL;
+ const struct audio_output_plugin *plugin = NULL;
if (param) {
const char *type = NULL;
@@ -82,21 +54,19 @@ int initAudioOutput(struct audio_output *ao, ConfigParam * param)
getBlockParam(AUDIO_OUTPUT_TYPE, type, 1);
getBlockParam(AUDIO_OUTPUT_FORMAT, format, 0);
- if (!findInList(audioOutputPluginList, type, &data)) {
+ plugin = audio_output_plugin_get(type);
+ if (plugin == NULL) {
FATAL("couldn't find audio output plugin for type "
"\"%s\" at line %i\n", type, param->line);
}
-
- plugin = (struct audio_output_plugin *) data;
} else {
- ListNode *node = audioOutputPluginList->firstNode;
+ unsigned i;
WARNING("No \"%s\" defined in config file\n",
CONF_AUDIO_OUTPUT);
WARNING("Attempt to detect audio output device\n");
- while (node) {
- plugin = (struct audio_output_plugin *) node->data;
+ audio_output_plugins_for_each(plugin, i) {
if (plugin->testDefaultDeviceFunc) {
WARNING("Attempting to detect a %s audio "
"device\n", plugin->name);
@@ -106,10 +76,9 @@ int initAudioOutput(struct audio_output *ao, ConfigParam * param)
break;
}
}
- node = node->nextNode;
}
- if (!node) {
+ if (plugin == NULL) {
WARNING("Unable to detect an audio device\n");
return 0;
}
@@ -250,14 +219,12 @@ void sendMetadataToAudioOutput(struct audio_output *audioOutput,
void printAllOutputPluginTypes(FILE * fp)
{
- ListNode *node = audioOutputPluginList->firstNode;
- struct audio_output_plugin *plugin;
+ unsigned i;
+ const struct audio_output_plugin *plugin;
- while (node) {
- plugin = (struct audio_output_plugin *) node->data;
+ audio_output_plugins_for_each(plugin, i)
fprintf(fp, "%s ", plugin->name);
- node = node->nextNode;
- }
+
fprintf(fp, "\n");
fflush(fp);
}