pulse-server: also handle @DEFAULT_*@ in GET_*_INFO

This commit is contained in:
Wim Taymans 2020-11-13 20:20:33 +01:00
parent b7b7c3817e
commit 13a1049abf

View file

@ -3668,6 +3668,7 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st
int res; int res;
struct pw_manager_object *o; struct pw_manager_object *o;
struct selector sel; struct selector sel;
const char *def = NULL;
int (*fill_func) (struct client *client, struct message *m, struct pw_manager_object *o) = NULL; int (*fill_func) (struct client *client, struct message *m, struct pw_manager_object *o) = NULL;
spa_zero(sel); spa_zero(sel);
@ -3698,11 +3699,13 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st
sel.type = is_sink; sel.type = is_sink;
sel.key = PW_KEY_NODE_NAME; sel.key = PW_KEY_NODE_NAME;
fill_func = fill_sink_info; fill_func = fill_sink_info;
def = "@DEFAULT_SINK@";
break; break;
case COMMAND_GET_SOURCE_INFO: case COMMAND_GET_SOURCE_INFO:
sel.type = is_source_or_monitor; sel.type = is_source_or_monitor;
sel.key = PW_KEY_NODE_NAME; sel.key = PW_KEY_NODE_NAME;
fill_func = fill_source_info; fill_func = fill_source_info;
def = "@DEFAULT_SOURCE@";
break; break;
case COMMAND_GET_SINK_INPUT_INFO: case COMMAND_GET_SINK_INPUT_INFO:
sel.type = is_sink_input; sel.type = is_sink_input;
@ -3726,6 +3729,9 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st
(sel.id != SPA_ID_INVALID && sel.value != NULL)) (sel.id != SPA_ID_INVALID && sel.value != NULL))
goto error_invalid; goto error_invalid;
if (sel.value != NULL && def != NULL && strcmp(sel.value, def) == 0)
sel.value = get_default(client, command == COMMAND_GET_SINK_INFO);
pw_log_info(NAME" %p: [%s] %s tag:%u idx:%u name:%s", impl, client->name, pw_log_info(NAME" %p: [%s] %s tag:%u idx:%u name:%s", impl, client->name,
commands[command].name, tag, sel.id, sel.value); commands[command].name, tag, sel.id, sel.value);