From 87628911452bfb59e4742efce70613ab3a6d0722 Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Thu, 12 Sep 2019 13:48:30 +0100 Subject: [PATCH] [streaming] configurable icy_metaint --- forked-daapd.conf.in | 5 +++++ src/conffile.c | 1 + src/httpd_streaming.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/forked-daapd.conf.in b/forked-daapd.conf.in index fec1523a..190c6b47 100644 --- a/forked-daapd.conf.in +++ b/forked-daapd.conf.in @@ -382,4 +382,9 @@ streaming { # Set the MP3 streaming bit rate (in kbps), valid options: 64 / 96 / 128 / 192 / 320 # bit_rate = 192 + + # Byte interval to send metadata to client, if requested. Should avoid + # low values to avoid audiable/stuttering problems with small input- + # bufffer clients. +# icy_metaint = 16384 } diff --git a/src/conffile.c b/src/conffile.c index 738e32c0..849decfd 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -194,6 +194,7 @@ static cfg_opt_t sec_streaming[] = CFG_INT("bits_per_sample", 16, CFGF_NONE), CFG_INT("channels", 2, CFGF_NONE), CFG_INT("bit_rate", 192, CFGF_NONE), + CFG_INT("icy_metaint", 16384, CFGF_NONE), CFG_END() }; diff --git a/src/httpd_streaming.c b/src/httpd_streaming.c index 1508c561..37aaf02f 100644 --- a/src/httpd_streaming.c +++ b/src/httpd_streaming.c @@ -94,7 +94,8 @@ static int streaming_meta[2]; * some devices with small input buffers, a higher quality stream and low * ICY_METAINT can lead to stuttering as observed on a Roku Soundbridge */ -static const short STREAMING_ICY_METAINT = 16384; +#define STREAMING_ICY_METAINT_DEFAULT 16384 +static unsigned short STREAMING_ICY_METAINT = STREAMING_ICY_METAINT_DEFAULT; static unsigned streaming_icy_clients; static char *streaming_icy_title; @@ -555,7 +556,7 @@ streaming_request(struct evhttp_request *req, struct httpd_uri_parsed *uri_parse if (param && strcmp(param, "1") == 0) require_icy = true; - DPRINTF(E_INFO, L_STREAMING, "Beginning mp3 streaming (with icy=%d) to %s:%d\n", require_icy, address, (int)port); + DPRINTF(E_INFO, L_STREAMING, "Beginning mp3 streaming (with icy=%d, icy_metaint=%d) to %s:%d\n", require_icy, STREAMING_ICY_METAINT, address, (int)port); lib = cfg_getsec(cfg, "library"); name = cfg_getstr(lib, "name"); @@ -659,6 +660,13 @@ streaming_init(void) } DPRINTF(E_INFO, L_STREAMING, "streaming quality: %d/%d/%d @ %dkbps\n", streaming_quality_out.sample_rate, streaming_quality_out.bits_per_sample, streaming_quality_out.channels, streaming_quality_out.bit_rate/1000); + val = cfg_getint(cfgsec, "icy_metaint"); + // Too low a value forces server to send more meta than data + if (val >= 4096 && val <= 131072) + STREAMING_ICY_METAINT = val; + else + DPRINTF(E_INFO, L_STREAMING, "icy_metaint=%d not accepted, defaulting to %d\n", val, STREAMING_ICY_METAINT); + pthread_mutex_init(&streaming_sessions_lck, NULL); // Non-blocking because otherwise httpd and player thread may deadlock