aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-09 16:36:06 +0100
committerMax Kellermann <max@duempel.org>2009-02-09 16:36:06 +0100
commitce2f1ba881bf83844b2fc7c2666f2e6741df58cc (patch)
tree60d81748a3c8f258ce49d203591ddaf8c4de4cd0
parent4228e50e25e3b4084797d4a2da2e2f3697a90651 (diff)
downloadmpd-ce2f1ba881bf83844b2fc7c2666f2e6741df58cc.tar.gz
mpd-ce2f1ba881bf83844b2fc7c2666f2e6741df58cc.tar.xz
mpd-ce2f1ba881bf83844b2fc7c2666f2e6741df58cc.zip
shout: don't postpone metadata
Don't duplicate the tag received by the send_metadata() method - send it to the shout server directly.
-rw-r--r--NEWS1
-rw-r--r--src/output/shout_mp3.c2
-rw-r--r--src/output/shout_plugin.c44
-rw-r--r--src/output/shout_plugin.h2
4 files changed, 15 insertions, 34 deletions
diff --git a/NEWS b/NEWS
index 04bd0bb06..2a4582528 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ ver 0.14.2 (2009/??/??)
- shout: fixed memory leak in the mp3 encoder
- shout: switch to blocking mode
- shout: use libshout's synchronization
+ - shout: don't postpone metadata
* mapper: remove trailing slashes from music_directory
* player: set player error when output device fails
diff --git a/src/output/shout_mp3.c b/src/output/shout_mp3.c
index 1369f6c80..86d39fc66 100644
--- a/src/output/shout_mp3.c
+++ b/src/output/shout_mp3.c
@@ -111,7 +111,7 @@ static int shout_mp3_encoder_send_metadata(struct shout_data *sd,
char artist[size];
char title[size];
int i;
- struct tag *tag = sd->tag;
+ const struct tag *tag = sd->tag;
strncpy(artist, "", size);
strncpy(title, "", size);
diff --git a/src/output/shout_plugin.c b/src/output/shout_plugin.c
index 993ba66ae..108c966dd 100644
--- a/src/output/shout_plugin.c
+++ b/src/output/shout_plugin.c
@@ -54,7 +54,6 @@ static struct shout_data *new_shout_data(void)
ret->shout_conn = shout_new();
ret->shout_meta = shout_metadata_new();
- ret->tag = NULL;
ret->bitrate = -1;
ret->quality = -2.0;
ret->timeout = DEFAULT_CONN_TIMEOUT;
@@ -69,8 +68,6 @@ static void free_shout_data(struct shout_data *sd)
shout_metadata_free(sd->shout_meta);
if (sd->shout_conn)
shout_free(sd->shout_conn);
- if (sd->tag)
- tag_free(sd->tag);
free(sd);
}
@@ -415,33 +412,11 @@ my_shout_open_device(void *data,
return true;
}
-static void send_metadata(struct shout_data * sd)
-{
- static const int size = 1024;
- char song[size];
-
- assert(sd->tag != NULL);
-
- if (sd->encoder->send_metadata_func(sd, song, size)) {
- shout_metadata_add(sd->shout_meta, "song", song);
- if (SHOUTERR_SUCCESS != shout_set_metadata(sd->shout_conn,
- sd->shout_meta)) {
- g_warning("error setting shout metadata\n");
- }
- }
-
- tag_free(sd->tag);
- sd->tag = NULL;
-}
-
static bool
my_shout_play(void *data, const char *chunk, size_t size)
{
struct shout_data *sd = (struct shout_data *)data;
- if (sd->tag != NULL)
- send_metadata(sd);
-
if (sd->encoder->encode_func(sd, chunk, size))
return false;
@@ -470,15 +445,20 @@ static void my_shout_set_tag(void *data,
const struct tag *tag)
{
struct shout_data *sd = (struct shout_data *)data;
+ char song[1024];
+ bool ret;
- if (sd->tag)
- tag_free(sd->tag);
- sd->tag = NULL;
-
- if (!tag)
- return;
+ sd->tag = tag;
+ ret = sd->encoder->send_metadata_func(sd, song, sizeof(song));
+ if (ret) {
+ shout_metadata_add(sd->shout_meta, "song", song);
+ if (SHOUTERR_SUCCESS != shout_set_metadata(sd->shout_conn,
+ sd->shout_meta)) {
+ g_warning("error setting shout metadata\n");
+ }
+ }
- sd->tag = tag_dup(tag);
+ write_page(sd);
}
const struct audio_output_plugin shoutPlugin = {
diff --git a/src/output/shout_plugin.h b/src/output/shout_plugin.h
index c11f2be66..823fd6e1a 100644
--- a/src/output/shout_plugin.h
+++ b/src/output/shout_plugin.h
@@ -67,7 +67,7 @@ struct shout_data {
float quality;
int bitrate;
- struct tag *tag;
+ const struct tag *tag;
int timeout;