From 5d18bcd4f2072c738bf3d9dd04c5ce9551591979 Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Thu, 28 Oct 2004 16:40:17 +0000 Subject: [PATCH] new clients should not depend on metadata settings from the source stream, however the interval can be stated in the xml file. svn path=/icecast/branches/kh/icecast/; revision=8128 --- src/format_mp3.c | 29 +++++++++++++++-------------- src/format_mp3.h | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/format_mp3.c b/src/format_mp3.c index c873000c..992c8bd2 100644 --- a/src/format_mp3.c +++ b/src/format_mp3.c @@ -98,6 +98,7 @@ int format_mp3_get_plugin (source_t *source) meta = refbuf_new (1); memcpy (meta->data, "", 1); state->metadata = meta; + state->interval = -1; metadata = httpp_getvar (source->parser, "icy-metaint"); if (metadata) @@ -185,7 +186,7 @@ static void format_mp3_apply_settings (source_t *source, mount_proxy *mount) { mp3_state *source_mp3 = source->format->_state; - source_mp3->interval = ICY_METADATA_INTERVAL; + source_mp3->interval = -1; if (mount->mp3_meta_interval >= 0) source_mp3->interval = mount->mp3_meta_interval; DEBUG2 ("mp3 interval %d, %d", mount->mp3_meta_interval, source_mp3->interval); @@ -574,6 +575,7 @@ static int format_mp3_create_client_data(source_t *source, client_t *client) { mp3_client_data *client_mp3 = calloc(1,sizeof(mp3_client_data)); mp3_state *source_mp3 = source->format->_state; + char *metadata = httpp_getvar(client->parser, "icy-metadata"); if (client_mp3 == NULL) { @@ -583,22 +585,21 @@ static int format_mp3_create_client_data(source_t *source, client_t *client) client->format_data = client_mp3; client->free_client_data = free_mp3_client_data; - if (source_mp3->interval > 0) - { - char *metadata = httpp_getvar(client->parser, "icy-metadata"); - if (metadata && atoi(metadata)) - { - unsigned remaining = client->predata_size - client->predata_len + 2; - char *ptr = client->predata + client->predata_len - 2; - int bytes; + if (metadata && atoi(metadata) && source_mp3->interval) + { + unsigned remaining = client->predata_size - client->predata_len + 2; + char *ptr = client->predata + client->predata_len - 2; + int bytes; + if (source_mp3->interval < 0) + client_mp3->interval = ICY_METADATA_INTERVAL; + else client_mp3->interval = source_mp3->interval; - bytes = snprintf (ptr, remaining, "icy-metaint:%u\r\n\r\n", - client_mp3->interval); - if (bytes > 0) - client->predata_len += bytes - 2; - } + bytes = snprintf (ptr, remaining, "icy-metaint:%u\r\n\r\n", + client_mp3->interval); + if (bytes > 0) + client->predata_len += bytes - 2; } return 0; diff --git a/src/format_mp3.h b/src/format_mp3.h index 8be1ec9a..7f6d73d3 100644 --- a/src/format_mp3.h +++ b/src/format_mp3.h @@ -22,7 +22,7 @@ typedef struct { /* These are for inline metadata */ int inline_metadata_interval; int offset; - unsigned interval; + int interval; char *url_artist; char *url_title; int update_metadata;