Commit 43ee3c3b authored by Eric Wollesen's avatar Eric Wollesen Committed by Max Kellermann

shout: send shout metadata

Support sending metadata to a shout server using shout_metadata_new() and shout_metadata_add(). The Ogg Vorbis encoder does not support this currently. [mk: this patch was separated from Eric's patch "Refactor and cleanup of shout Ogg and MP3 audio outputs", I added a description]
parent 1333c392
...@@ -40,6 +40,7 @@ static struct shout_data *new_shout_data(void) ...@@ -40,6 +40,7 @@ static struct shout_data *new_shout_data(void)
struct shout_data *ret = xmalloc(sizeof(*ret)); struct shout_data *ret = xmalloc(sizeof(*ret));
ret->shout_conn = shout_new(); ret->shout_conn = shout_new();
ret->shout_meta = shout_metadata_new();
ret->opened = 0; ret->opened = 0;
ret->tag = NULL; ret->tag = NULL;
ret->tag_to_send = 0; ret->tag_to_send = 0;
...@@ -59,6 +60,8 @@ static struct shout_data *new_shout_data(void) ...@@ -59,6 +60,8 @@ static struct shout_data *new_shout_data(void)
static void free_shout_data(struct shout_data *sd) static void free_shout_data(struct shout_data *sd)
{ {
if (sd->shout_meta)
shout_metadata_free(sd->shout_meta);
if (sd->shout_conn) if (sd->shout_conn)
shout_free(sd->shout_conn); shout_free(sd->shout_conn);
if (sd->tag) if (sd->tag)
...@@ -427,12 +430,19 @@ static int my_shout_open_device(struct audio_output *audio_output) ...@@ -427,12 +430,19 @@ static int my_shout_open_device(struct audio_output *audio_output)
static void send_metadata(struct shout_data * sd) static void send_metadata(struct shout_data * sd)
{ {
static const int size = 1024;
char song[size];
if (!sd->opened || !sd->tag) if (!sd->opened || !sd->tag)
return; return;
if (shout_ogg_encoder_send_metadata(sd)) { if (shout_ogg_encoder_send_metadata(sd, song, size)) {
close_shout_conn(sd); shout_metadata_add(sd->shout_meta, "song", song);
return; if (SHOUTERR_SUCCESS != shout_set_metadata(sd->shout_conn,
sd->shout_meta)) {
ERROR("error setting shout metadata\n");
return;
}
} }
sd->tag_to_send = 0; sd->tag_to_send = 0;
......
...@@ -51,6 +51,7 @@ typedef struct _ogg_vorbis_data { ...@@ -51,6 +51,7 @@ typedef struct _ogg_vorbis_data {
struct shout_data { struct shout_data {
shout_t *shout_conn; shout_t *shout_conn;
shout_metadata_t *shout_meta;
int shout_error; int shout_error;
ogg_vorbis_data od; ogg_vorbis_data od;
...@@ -83,7 +84,8 @@ int shout_ogg_encoder_clear_encoder(struct shout_data *sd); ...@@ -83,7 +84,8 @@ int shout_ogg_encoder_clear_encoder(struct shout_data *sd);
int init_encoder(struct shout_data *sd); int init_encoder(struct shout_data *sd);
int shout_ogg_encoder_send_metadata(struct shout_data * sd); int shout_ogg_encoder_send_metadata(struct shout_data * sd,
char *song, size_t size);
void shout_ogg_encoder_encode(struct shout_data *sd, void shout_ogg_encoder_encode(struct shout_data *sd,
const char *chunk, size_t len); const char *chunk, size_t len);
......
...@@ -186,7 +186,9 @@ int init_encoder(struct shout_data *sd) ...@@ -186,7 +186,9 @@ int init_encoder(struct shout_data *sd)
return 0; return 0;
} }
int shout_ogg_encoder_send_metadata(struct shout_data * sd) int shout_ogg_encoder_send_metadata(struct shout_data * sd,
mpd_unused char * song,
mpd_unused size_t size)
{ {
ogg_vorbis_data *od = &sd->od; ogg_vorbis_data *od = &sd->od;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment