diff --git a/src/cfgfile.c b/src/cfgfile.c index e4b1db16..cbf0c66a 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -1263,6 +1263,7 @@ static void _parse_mount(xmlDocPtr doc, mount->burst_size = -1; mount->mp3_meta_interval = -1; mount->yp_public = -1; + mount->max_history = -1; mount->next = NULL; tmp = (char *)xmlGetProp(node, XMLSTR("type")); @@ -1315,6 +1316,13 @@ static void _parse_mount(xmlDocPtr doc, mount->max_listeners = atoi(tmp); if(tmp) xmlFree(tmp); + } else if (xmlStrcmp(node->name, XMLSTR("max-history")) == 0) { + tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); + mount->max_history = atoi(tmp); + if (mount->max_history < 1 || mount->max_history > 256) + mount->max_history = 256; /* deny super huge values */ + if(tmp) + xmlFree(tmp); } else if (xmlStrcmp(node->name, XMLSTR("charset")) == 0) { mount->charset = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); @@ -2240,6 +2248,8 @@ static void merge_mounts(mount_proxy * dst, mount_proxy * src) dst->subtype = (char*)xmlStrdup((xmlChar*)src->subtype); if (dst->yp_public == -1) dst->yp_public = src->yp_public; + if (dst->max_history == -1) + dst->max_history = src->max_history; if (dst->http_headers) { http_header_next = dst->http_headers; diff --git a/src/cfgfile.h b/src/cfgfile.h index 93d6e9ff..d18725c6 100644 --- a/src/cfgfile.h +++ b/src/cfgfile.h @@ -134,6 +134,9 @@ typedef struct _mount_proxy { /* additional HTTP headers */ ice_config_http_header_t *http_headers; + /* maximum history size of played songs */ + ssize_t max_history; + struct event_registration_tag *event; char *cluster_password; diff --git a/src/source.c b/src/source.c index 003dd240..42a37757 100644 --- a/src/source.c +++ b/src/source.c @@ -100,7 +100,7 @@ source_t *source_reserve (const char *mount) src->client_tree = avl_tree_new(_compare_clients, NULL); src->pending_tree = avl_tree_new(_compare_clients, NULL); - src->history = playlist_new(-1); + src->history = playlist_new(4 /* DOCUMENT: default is max_tracks=4. */); /* make duplicates for strings or similar */ src->mount = strdup(mount); @@ -1216,6 +1216,9 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr if (mountinfo && mountinfo->fallback_when_full) source->fallback_when_full = mountinfo->fallback_when_full; + if (mountinfo && mountinfo->max_history > 0) + playlist_set_max_tracks(source->history, mountinfo->max_history); + avl_tree_unlock(source->client_tree); }