From 0903dd68ed29db71e6841f87f511452e0ace8ba7 Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Wed, 31 Aug 2005 01:28:04 +0000 Subject: [PATCH] 2 updates to mp3 metadata handling. allow a 0 metadata interval to disable metadata being sent to new listeners (negative for whatever the source sends), existing listeners retain their original interval setting. We now limit how much mp3 is written after the metadata block in a single format send call, this was only showing up on small interval values. svn path=/icecast/trunk/icecast/; revision=9877 --- src/format_mp3.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/format_mp3.c b/src/format_mp3.c index d6ecef36..953662f9 100644 --- a/src/format_mp3.c +++ b/src/format_mp3.c @@ -197,7 +197,7 @@ static void format_mp3_apply_settings (client_t *client, format_plugin_t *format { mp3_state *source_mp3 = format->_state; - if (mount == NULL || mount->mp3_meta_interval <= 0) + if (mount == NULL || mount->mp3_meta_interval < 0) { char *metadata = httpp_getvar (client->parser, "icy-metaint"); source_mp3->interval = -1; @@ -376,6 +376,9 @@ static int format_mp3_write_buf_to_client(client_t *client) /* change buf and len */ buf += remaining; len -= remaining; + /* limit how much mp3 we send if using small intervals */ + if (len > client_mp3->interval) + len = client_mp3->interval; } } /* write any mp3, maybe after the metadata block */ @@ -635,16 +638,19 @@ static int format_mp3_create_client_data(source_t *source, client_t *client) metadata = httpp_getvar(client->parser, "icy-metadata"); if (metadata && atoi(metadata)) { - if (source_mp3->interval > 0) + if (source_mp3->interval >= 0) client_mp3->interval = source_mp3->interval; else client_mp3->interval = ICY_METADATA_INTERVAL; - bytes = snprintf (ptr, remaining, "icy-metaint:%u\r\n", - client_mp3->interval); - if (bytes > 0) + if (client_mp3->interval) { - remaining -= bytes; - ptr += bytes; + bytes = snprintf (ptr, remaining, "icy-metaint:%u\r\n", + client_mp3->interval); + if (bytes > 0) + { + remaining -= bytes; + ptr += bytes; + } } } bytes = snprintf (ptr, remaining, "\r\n");