From cfe43cbea746aa09de979be2972350071a4921c9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 5 Dec 2020 13:30:02 +0100 Subject: [PATCH] pulse-server: handle NULL as default sink/source Fixes #444 --- src/modules/module-protocol-pulse/pulse-server.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index f6416fd55..44dbc4fa4 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -2759,7 +2759,8 @@ static struct pw_manager_object *find_device(struct client *client, sel.type = object_is_source; def = DEFAULT_SOURCE; } - if (sel.value != NULL && strcmp(sel.value, def) == 0) + if (id == SPA_ID_INVALID && + (sel.value == NULL || strcmp(sel.value, def) == 0)) sel.value = get_default(client, sink); return select_object(client->manager, &sel); @@ -3174,8 +3175,6 @@ static int do_lookup(struct client *client, uint32_t command, uint32_t tag, stru TAG_STRING, &name, TAG_INVALID)) < 0) return -EPROTO; - if (name == NULL) - return -EINVAL; pw_log_info(NAME" %p: [%s] LOOKUP tag:%u name:'%s'", impl, client->name, tag, name); @@ -3856,11 +3855,10 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st if (fill_func == NULL) goto error_invalid; - if ((sel.id == SPA_ID_INVALID && sel.value == NULL) || - (sel.id != SPA_ID_INVALID && sel.value != NULL)) + if (sel.id != SPA_ID_INVALID && sel.value != NULL) goto error_invalid; - if (sel.value != NULL && def != NULL && strcmp(sel.value, def) == 0) + 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, @@ -4243,9 +4241,6 @@ static int do_set_default(struct client *client, uint32_t command, uint32_t tag, TAG_INVALID)) < 0) return -EPROTO; - if (name == NULL) - return -EINVAL; - pw_log_info(NAME" %p: [%s] %s tag:%u name:%s", impl, client->name, commands[command].name, tag, name);