diff options
author | Max Kellermann <max@duempel.org> | 2008-09-12 16:39:51 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-12 16:39:51 +0200 |
commit | d9f170b5dbad075a4cc3651054bd1751c3f66fbc (patch) | |
tree | 2194ba5555de7339647eb1e9d521e7a8769d625a /src/audioOutputs | |
parent | a84de9b0101b60836c3d22baf1e6d163aa091f6c (diff) | |
download | mpd-d9f170b5dbad075a4cc3651054bd1751c3f66fbc.tar.gz mpd-d9f170b5dbad075a4cc3651054bd1751c3f66fbc.tar.xz mpd-d9f170b5dbad075a4cc3651054bd1751c3f66fbc.zip |
shout: static encoder plugin list
Shout encoder plugins are known at compile time. There is no reason
to use a complex data structure as "List" to manage them at runtime -
just put the pointers into a static array.
Diffstat (limited to '')
-rw-r--r-- | src/audioOutputs/audioOutput_shout.c | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index 8816b57f4..3771ccdc4 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -20,7 +20,6 @@ #ifdef HAVE_SHOUT -#include "../list.h" #include "../utils.h" #define CONN_ATTEMPT_INTERVAL 60 @@ -29,32 +28,23 @@ #define SHOUT_BUF_SIZE 8192 static int shout_init_count; -static List *shout_encoder_plugin_list; -mpd_unused -static void finish_shout_encoder_plugins(void) -{ - freeList(shout_encoder_plugin_list); -} +static struct shout_encoder_plugin *const shout_encoder_plugins[] = { + &shout_mp3_encoder, + &shout_ogg_encoder, + NULL +}; -static void init_shout_encoder_plugins(void) +static struct shout_encoder_plugin * +shout_encoder_plugin_get(const char *name) { - shout_encoder_plugin_list = makeList(NULL, 0); -} + unsigned i; -static void load_shout_encoder_plugin(struct shout_encoder_plugin * plugin) -{ - if (!plugin->name) - return; - insertInList(shout_encoder_plugin_list, plugin->name, plugin); -} + for (i = 0; shout_encoder_plugins[i] != NULL; ++i) + if (strcmp(shout_encoder_plugins[i]->name, name) == 0) + return shout_encoder_plugins[i]; -mpd_unused -static void unload_shout_encoder_plugin(struct shout_encoder_plugin * plugin) -{ - if (!plugin->name) - return; - deleteFromList(shout_encoder_plugin_list, plugin->name); + return NULL; } static void clear_shout_buffer(struct shout_data * sd) @@ -110,13 +100,6 @@ static void free_shout_data(struct shout_data *sd) } \ } -static void load_shout_plugins(void) -{ - init_shout_encoder_plugins(); - load_shout_encoder_plugin(&shout_mp3_encoder); - load_shout_encoder_plugin(&shout_ogg_encoder); -} - static int my_shout_init_driver(struct audio_output *audio_output, ConfigParam * param) { @@ -131,9 +114,6 @@ static int my_shout_init_driver(struct audio_output *audio_output, char *name; BlockParam *block_param; int public; - void *data = NULL; - - load_shout_plugins(); sd = new_shout_data(); @@ -225,11 +205,11 @@ static int my_shout_init_driver(struct audio_output *audio_output, } else { encoding = "ogg"; } - if (!findInList(shout_encoder_plugin_list, encoding, &data)) { + + sd->encoder = shout_encoder_plugin_get(encoding); + if (sd->encoder == NULL) FATAL("couldn't find shout encoder plugin for \"%s\" " "at line %i\n", encoding, block_param->line); - } - sd->encoder = (struct shout_encoder_plugin *) data; if (shout_set_host(sd->shout_conn, host) != SHOUTERR_SUCCESS || shout_set_port(sd->shout_conn, port) != SHOUTERR_SUCCESS || |