diff options
author | Max Kellermann <max@duempel.org> | 2008-09-12 16:38:54 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-12 16:38:54 +0200 |
commit | a84de9b0101b60836c3d22baf1e6d163aa091f6c (patch) | |
tree | ab3758f6c75078534e91641a5319857d93e19797 /src | |
parent | 5f8eebd122ebf49bfcb6b6d6c6063bb1a932e7ff (diff) | |
download | mpd-a84de9b0101b60836c3d22baf1e6d163aa091f6c.tar.gz mpd-a84de9b0101b60836c3d22baf1e6d163aa091f6c.tar.xz mpd-a84de9b0101b60836c3d22baf1e6d163aa091f6c.zip |
shout: removed typedefs on structs and plugin methods
Don't typedef the structs at all. It is easier to forward-declare
this way.
Don't typedef methods. They are used exactly once, a few lines below.
Diffstat (limited to 'src')
-rw-r--r-- | src/audioOutputs/audioOutput_shout.c | 6 | ||||
-rw-r--r-- | src/audioOutputs/audioOutput_shout.h | 61 | ||||
-rw-r--r-- | src/audioOutputs/audioOutput_shout_mp3.c | 35 | ||||
-rw-r--r-- | src/audioOutputs/audioOutput_shout_ogg.c | 36 |
4 files changed, 65 insertions, 73 deletions
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index 82a68fa9f..8816b57f4 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -42,7 +42,7 @@ static void init_shout_encoder_plugins(void) shout_encoder_plugin_list = makeList(NULL, 0); } -static void load_shout_encoder_plugin(shout_encoder_plugin * plugin) +static void load_shout_encoder_plugin(struct shout_encoder_plugin * plugin) { if (!plugin->name) return; @@ -50,7 +50,7 @@ static void load_shout_encoder_plugin(shout_encoder_plugin * plugin) } mpd_unused -static void unload_shout_encoder_plugin(shout_encoder_plugin * plugin) +static void unload_shout_encoder_plugin(struct shout_encoder_plugin * plugin) { if (!plugin->name) return; @@ -229,7 +229,7 @@ static int my_shout_init_driver(struct audio_output *audio_output, FATAL("couldn't find shout encoder plugin for \"%s\" " "at line %i\n", encoding, block_param->line); } - sd->encoder = (shout_encoder_plugin *) data; + 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 || diff --git a/src/audioOutputs/audioOutput_shout.h b/src/audioOutputs/audioOutput_shout.h index 14f6b00a7..6657e3c70 100644 --- a/src/audioOutputs/audioOutput_shout.h +++ b/src/audioOutputs/audioOutput_shout.h @@ -28,50 +28,43 @@ #include <shout/shout.h> -#define DISABLED_SHOUT_ENCODER_PLUGIN(plugin) shout_encoder_plugin plugin; - -typedef struct shout_data shout_data; - -typedef int (*shout_encoder_clear_encoder_func) (shout_data * sd); -typedef int (*shout_encoder_encode_func) (shout_data * sd, - const char * chunk, - size_t len); -typedef void (*shout_encoder_finish_func) (shout_data * sd); -typedef int (*shout_encoder_init_func) (shout_data * sd); -typedef int (*shout_encoder_init_encoder_func) (shout_data * sd); -/* Called when there is a new MpdTag to encode into the stream. If - this function returns non-zero, then the resulting song will be - passed to the shout server as metadata. This allows the Ogg - encoder to send metadata via Vorbis comments in the stream, while - an MP3 encoder can use the Shout Server's metadata API. */ -typedef int (*shout_encoder_send_metadata_func) (shout_data * sd, - char * song, - size_t size); - -typedef struct _shout_encoder_plugin { +#define DISABLED_SHOUT_ENCODER_PLUGIN(plugin) \ + struct shout_encoder_plugin plugin; + +struct shout_data; + +struct shout_encoder_plugin { const char *name; unsigned int shout_format; - shout_encoder_clear_encoder_func clear_encoder_func; - shout_encoder_encode_func encode_func; - shout_encoder_finish_func finish_func; - shout_encoder_init_func init_func; - shout_encoder_init_encoder_func init_encoder_func; - shout_encoder_send_metadata_func send_metadata_func; -} shout_encoder_plugin; + int (*clear_encoder_func)(struct shout_data *sd); + int (*encode_func)(struct shout_data *sd, + const char *chunk, size_t len); + void (*finish_func)(struct shout_data *sd); + int (*init_func)(struct shout_data *sd); + int (*init_encoder_func) (struct shout_data *sd); + /* Called when there is a new MpdTag to encode into the + stream. If this function returns non-zero, then the + resulting song will be passed to the shout server as + metadata. This allows the Ogg encoder to send metadata via + Vorbis comments in the stream, while an MP3 encoder can use + the Shout Server's metadata API. */ + int (*send_metadata_func)(struct shout_data *sd, + char *song, size_t size); +}; -typedef struct _shout_buffer { +struct shout_buffer { unsigned char *data; size_t len; size_t max_len; -} shout_buffer; +}; struct shout_data { shout_t *shout_conn; shout_metadata_t *shout_meta; int shout_error; - shout_encoder_plugin *encoder; + struct shout_encoder_plugin *encoder; void *encoder_data; float quality; @@ -91,11 +84,11 @@ struct shout_data { /* the configured audio format */ struct audio_format audio_format; - shout_buffer buf; + struct shout_buffer buf; }; -extern shout_encoder_plugin shout_mp3_encoder; -extern shout_encoder_plugin shout_ogg_encoder; +extern struct shout_encoder_plugin shout_mp3_encoder; +extern struct shout_encoder_plugin shout_ogg_encoder; #endif diff --git a/src/audioOutputs/audioOutput_shout_mp3.c b/src/audioOutputs/audioOutput_shout_mp3.c index 388808c1b..4bdccfd2d 100644 --- a/src/audioOutputs/audioOutput_shout_mp3.c +++ b/src/audioOutputs/audioOutput_shout_mp3.c @@ -24,26 +24,26 @@ #include "audioOutput_shout.h" #include <lame/lame.h> -typedef struct _lame_data { +struct lame_data { lame_global_flags *gfp; -} lame_data; +}; -static int shout_mp3_encoder_init(shout_data * sd) +static int shout_mp3_encoder_init(struct shout_data *sd) { - lame_data *ld; + struct lame_data *ld; - if (NULL == (ld = xmalloc(sizeof(lame_data)))) + if (NULL == (ld = xmalloc(sizeof(*ld)))) FATAL("error initializing lame encoder data\n"); sd->encoder_data = ld; return 0; } -static int shout_mp3_encoder_clear_encoder(shout_data * sd) +static int shout_mp3_encoder_clear_encoder(struct shout_data *sd) { - lame_data *ld = (lame_data *)sd->encoder_data; - shout_buffer *buf = &sd->buf; + struct lame_data *ld = (struct lame_data *)sd->encoder_data; + struct shout_buffer *buf = &sd->buf; int ret; if ((ret = lame_encode_flush(ld->gfp, buf->data + buf->len, @@ -53,17 +53,17 @@ static int shout_mp3_encoder_clear_encoder(shout_data * sd) return (ret > 0); } -static void shout_mp3_encoder_finish(shout_data * sd) +static void shout_mp3_encoder_finish(struct shout_data *sd) { - lame_data *ld = (lame_data *)sd->encoder_data; + struct lame_data *ld = (struct lame_data *)sd->encoder_data; lame_close(ld->gfp); ld->gfp = NULL; } -static int shout_mp3_encoder_init_encoder(shout_data * sd) +static int shout_mp3_encoder_init_encoder(struct shout_data *sd) { - lame_data *ld = (lame_data *)sd->encoder_data; + struct lame_data *ld = (struct lame_data *)sd->encoder_data; if (NULL == (ld->gfp = lame_init())) { ERROR("error initializing lame encoder for shout\n"); @@ -104,7 +104,7 @@ static int shout_mp3_encoder_init_encoder(shout_data * sd) return 0; } -static int shout_mp3_encoder_send_metadata(shout_data * sd, +static int shout_mp3_encoder_send_metadata(struct shout_data *sd, char * song, size_t size) { char artist[size]; @@ -133,16 +133,16 @@ static int shout_mp3_encoder_send_metadata(shout_data * sd, return 1; } -static int shout_mp3_encoder_encode(shout_data * sd, +static int shout_mp3_encoder_encode(struct shout_data *sd, const char * chunk, size_t len) { unsigned int i; int j; float (*lamebuf)[2]; - shout_buffer *buf = &(sd->buf); + struct shout_buffer *buf = &(sd->buf); unsigned int samples; int bytes = sd->audio_format.bits / 8; - lame_data *ld = (lame_data *)sd->encoder_data; + struct lame_data *ld = (struct lame_data *)sd->encoder_data; int bytes_out; samples = len / (bytes * sd->audio_format.channels); @@ -174,8 +174,7 @@ static int shout_mp3_encoder_encode(shout_data * sd, return 0; } - -shout_encoder_plugin shout_mp3_encoder = { +struct shout_encoder_plugin shout_mp3_encoder = { "mp3", SHOUT_FORMAT_MP3, diff --git a/src/audioOutputs/audioOutput_shout_ogg.c b/src/audioOutputs/audioOutput_shout_ogg.c index 5e0adf4d0..327c90b24 100644 --- a/src/audioOutputs/audioOutput_shout_ogg.c +++ b/src/audioOutputs/audioOutput_shout_ogg.c @@ -23,7 +23,7 @@ #include "../utils.h" #include <vorbis/vorbisenc.h> -typedef struct _ogg_vorbis_data { +struct ogg_vorbis_data { ogg_stream_state os; ogg_page og; ogg_packet op; @@ -35,9 +35,9 @@ typedef struct _ogg_vorbis_data { vorbis_block vb; vorbis_info vi; vorbis_comment vc; -} ogg_vorbis_data; +}; -static void add_tag(ogg_vorbis_data *od, const char *name, char *value) +static void add_tag(struct ogg_vorbis_data *od, const char *name, char *value) { if (value) { union const_hack u; @@ -48,7 +48,7 @@ static void add_tag(ogg_vorbis_data *od, const char *name, char *value) static void copy_tag_to_vorbis_comment(struct shout_data *sd) { - ogg_vorbis_data *od = (ogg_vorbis_data *)sd->encoder_data; + struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data; if (sd->tag) { int i; @@ -73,7 +73,7 @@ static void copy_tag_to_vorbis_comment(struct shout_data *sd) } static int copy_ogg_buffer_to_shout_buffer(ogg_page *og, - shout_buffer *buf) + struct shout_buffer *buf) { if (buf->max_len - buf->len >= (size_t)og->header_len) { memcpy(buf->data + buf->len, @@ -98,8 +98,8 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og, static int flush_ogg_buffer(struct shout_data *sd) { - shout_buffer *buf = &sd->buf; - ogg_vorbis_data *od = (ogg_vorbis_data *)sd->encoder_data; + struct shout_buffer *buf = &sd->buf; + struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data; int ret = 0; if (ogg_stream_flush(&od->os, &od->og)) @@ -110,7 +110,7 @@ static int flush_ogg_buffer(struct shout_data *sd) static int send_ogg_vorbis_header(struct shout_data *sd) { - ogg_vorbis_data *od = (ogg_vorbis_data *)sd->encoder_data; + struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data; vorbis_analysis_headerout(&od->vd, &od->vc, &od->header_main, @@ -124,7 +124,7 @@ static int send_ogg_vorbis_header(struct shout_data *sd) return flush_ogg_buffer(sd); } -static void finish_encoder(ogg_vorbis_data *od) +static void finish_encoder(struct ogg_vorbis_data *od) { vorbis_analysis_wrote(&od->vd, 0); @@ -139,7 +139,7 @@ static void finish_encoder(ogg_vorbis_data *od) static int shout_ogg_encoder_clear_encoder(struct shout_data *sd) { - ogg_vorbis_data *od = (ogg_vorbis_data *)sd->encoder_data; + struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data; int ret; finish_encoder(od); @@ -157,7 +157,7 @@ static int shout_ogg_encoder_clear_encoder(struct shout_data *sd) static void shout_ogg_encoder_finish(struct shout_data *sd) { - ogg_vorbis_data *od = (ogg_vorbis_data *)sd->encoder_data; + struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data; if (od) { free(od); @@ -167,9 +167,9 @@ static void shout_ogg_encoder_finish(struct shout_data *sd) static int shout_ogg_encoder_init(struct shout_data *sd) { - ogg_vorbis_data *od; + struct ogg_vorbis_data *od; - if (NULL == (od = xmalloc(sizeof(ogg_vorbis_data)))) + if (NULL == (od = xmalloc(sizeof(*od)))) FATAL("error initializing ogg vorbis encoder data\n"); sd->encoder_data = od; @@ -178,7 +178,7 @@ static int shout_ogg_encoder_init(struct shout_data *sd) static int reinit_encoder(struct shout_data *sd) { - ogg_vorbis_data *od = (ogg_vorbis_data *)sd->encoder_data; + struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data; vorbis_info_init(&od->vi); @@ -227,7 +227,7 @@ static int shout_ogg_encoder_send_metadata(struct shout_data *sd, mpd_unused char * song, mpd_unused size_t size) { - ogg_vorbis_data *od = (ogg_vorbis_data *)sd->encoder_data; + struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data; shout_ogg_encoder_clear_encoder(sd); if (reinit_encoder(sd)) @@ -252,13 +252,13 @@ static int shout_ogg_encoder_send_metadata(struct shout_data *sd, static int shout_ogg_encoder_encode(struct shout_data *sd, const char *chunk, size_t size) { - shout_buffer *buf = &sd->buf; + struct shout_buffer *buf = &sd->buf; unsigned int i; int j; float **vorbbuf; unsigned int samples; int bytes = sd->audio_format.bits / 8; - ogg_vorbis_data *od = (ogg_vorbis_data *)sd->encoder_data; + struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data; samples = size / (bytes * sd->audio_format.channels); vorbbuf = vorbis_analysis_buffer(&od->vd, samples); @@ -289,7 +289,7 @@ static int shout_ogg_encoder_encode(struct shout_data *sd, return 0; } -shout_encoder_plugin shout_ogg_encoder = { +struct shout_encoder_plugin shout_ogg_encoder = { "ogg", SHOUT_FORMAT_VORBIS, |