mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: Made fallback_override an enum
This commit is contained in:
parent
2e148986f9
commit
c60a2113c9
@ -217,6 +217,25 @@ static listener_type_t config_str_to_listener_type(const char *str)
|
||||
}
|
||||
}
|
||||
|
||||
static fallback_override_t config_str_to_fallback_override_t(const char *str)
|
||||
{
|
||||
if (!str || !*str || strcmp(str, "none") == 0) {
|
||||
return FALLBACK_OVERRIDE_NONE;
|
||||
} else if (strcasecmp(str, "all") == 0) {
|
||||
return FALLBACK_OVERRIDE_ALL;
|
||||
} else if (strcasecmp(str, "own") == 0) {
|
||||
return FALLBACK_OVERRIDE_OWN;
|
||||
} else {
|
||||
if (util_str_to_bool(str)) {
|
||||
ICECAST_LOG_WARN("Old style fallback override setting. Please replace %#H with \"all\".", str);
|
||||
return FALLBACK_OVERRIDE_ALL;
|
||||
} else {
|
||||
ICECAST_LOG_WARN("Old style fallback override setting. Please replace %#H with \"none\".", str);
|
||||
return FALLBACK_OVERRIDE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char * config_href_to_id(const char *href)
|
||||
{
|
||||
if (!href || !*href)
|
||||
@ -1538,7 +1557,7 @@ static void _parse_mount(xmlDocPtr doc,
|
||||
__read_int(doc, node, &mount->mp3_meta_interval, "<icy-metadata-interval> must not be empty.");
|
||||
} else if (xmlStrcmp(node->name, XMLSTR("fallback-override")) == 0) {
|
||||
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
mount->fallback_override = util_str_to_bool(tmp);
|
||||
mount->fallback_override = config_str_to_fallback_override_t(tmp);
|
||||
if(tmp)
|
||||
xmlFree(tmp);
|
||||
} else if (xmlStrcmp(node->name, XMLSTR("no-mount")) == 0) {
|
||||
@ -1695,7 +1714,7 @@ static void _parse_mount(xmlDocPtr doc,
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
if (!mount->fallback_mount && (mount->fallback_when_full || mount->fallback_override)) {
|
||||
if (!mount->fallback_mount && (mount->fallback_when_full || mount->fallback_override != FALLBACK_OVERRIDE_NONE)) {
|
||||
ICECAST_LOG_WARN("Config for mount %s contains fallback options "
|
||||
"but no fallback mount.", mount->mountname);
|
||||
}
|
||||
@ -2675,7 +2694,7 @@ static void merge_mounts(mount_proxy * dst, mount_proxy * src)
|
||||
dst->max_listeners = src->max_listeners;
|
||||
if (!dst->fallback_mount)
|
||||
dst->fallback_mount = (char*)xmlStrdup((xmlChar*)src->fallback_mount);
|
||||
if (!dst->fallback_override)
|
||||
if (dst->fallback_override == FALLBACK_OVERRIDE_NONE)
|
||||
dst->fallback_override = src->fallback_override;
|
||||
if (!dst->no_mount)
|
||||
dst->no_mount = src->no_mount;
|
||||
|
@ -67,6 +67,12 @@ typedef enum _mount_type {
|
||||
MOUNT_TYPE_DEFAULT
|
||||
} mount_type;
|
||||
|
||||
typedef enum {
|
||||
FALLBACK_OVERRIDE_NONE = 0,
|
||||
FALLBACK_OVERRIDE_ALL,
|
||||
FALLBACK_OVERRIDE_OWN
|
||||
} fallback_override_t;
|
||||
|
||||
typedef struct _mount_proxy {
|
||||
/* The mountpoint this proxy is used for */
|
||||
char *mountname;
|
||||
@ -89,7 +95,7 @@ typedef struct _mount_proxy {
|
||||
/* When this source arrives, do we steal back
|
||||
* clients from the fallback?
|
||||
*/
|
||||
int fallback_override;
|
||||
fallback_override_t fallback_override;
|
||||
/* Do we permit direct requests of this mountpoint?
|
||||
* (or only indirect, through fallbacks)
|
||||
*/
|
||||
|
@ -538,7 +538,7 @@ static void check_relay_stream (relay_t *relay)
|
||||
{
|
||||
relay->source->on_demand = relay->config->on_demand;
|
||||
|
||||
if (source->fallback_mount && source->fallback_override)
|
||||
if (source->fallback_mount && source->fallback_override != FALLBACK_OVERRIDE_NONE)
|
||||
{
|
||||
source_t *fallback;
|
||||
avl_tree_rlock (global.source_tree);
|
||||
|
20
src/source.c
20
src/source.c
@ -660,15 +660,27 @@ static void source_init (source_t *source)
|
||||
** loop or jingle track or whatever the fallback is used for
|
||||
*/
|
||||
|
||||
if (source->fallback_override && source->fallback_mount)
|
||||
{
|
||||
ICECAST_LOG_DDEBUG("source=%p{.mount=%#H, .fallback_override=%i, .fallback_mount=%#H, ...}", source, source->mount, (int)source->fallback_override, source->fallback_mount);
|
||||
if (source->fallback_override != FALLBACK_OVERRIDE_NONE && source->fallback_mount) {
|
||||
source_t *fallback_source;
|
||||
|
||||
avl_tree_rlock(global.source_tree);
|
||||
fallback_source = source_find_mount(source->fallback_mount);
|
||||
|
||||
if (fallback_source)
|
||||
source_move_clients(fallback_source, source, NULL, NAVIGATION_DIRECTION_UP);
|
||||
if (fallback_source) {
|
||||
ICECAST_LOG_DDEBUG("source=%p{.mount=%#H, .fallback_override=%i, ...}, fallback_source=%p{.mount=%#H, ...}", source, source->mount, (int)source->fallback_override, fallback_source, fallback_source->mount);
|
||||
switch (source->fallback_override) {
|
||||
case FALLBACK_OVERRIDE_NONE:
|
||||
/* no-op */
|
||||
break;
|
||||
case FALLBACK_OVERRIDE_ALL:
|
||||
source_move_clients(fallback_source, source, NULL, NAVIGATION_DIRECTION_REPLACE_CURRENT);
|
||||
break;
|
||||
case FALLBACK_OVERRIDE_OWN:
|
||||
source_move_clients(fallback_source, source, NULL, NAVIGATION_DIRECTION_UP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
avl_tree_unlock(global.source_tree);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ struct source_tag {
|
||||
unsigned long prev_listeners;
|
||||
long max_listeners;
|
||||
int yp_public;
|
||||
int fallback_override;
|
||||
fallback_override_t fallback_override;
|
||||
int fallback_when_full;
|
||||
int shoutcast_compat;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user