From 1b09640b6f9f76348ef2ebebb3826d49812fac88 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 13 Oct 2021 15:38:59 +0200 Subject: [PATCH] pulse-server: use find_device for get_info of a device So that we also go through the same logic for finding the default source and sink when needed. --- .../module-protocol-pulse/pulse-server.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 47276f7dc..8f7af07f8 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -3916,7 +3916,6 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st int res; struct pw_manager_object *o; struct selector sel; - const char *def = NULL; int (*fill_func) (struct client *client, struct message *m, struct pw_manager_object *o) = NULL; spa_zero(sel); @@ -3955,13 +3954,11 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st sel.type = pw_manager_object_is_sink; sel.key = PW_KEY_NODE_NAME; fill_func = fill_sink_info; - def = DEFAULT_SINK; break; case COMMAND_GET_SOURCE_INFO: sel.type = pw_manager_object_is_source_or_monitor; sel.key = PW_KEY_NODE_NAME; fill_func = fill_source_info; - def = DEFAULT_SOURCE; break; case COMMAND_GET_SINK_INPUT_INFO: sel.type = pw_manager_object_is_sink_input; @@ -3988,22 +3985,13 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st commands[command].name, tag, sel.id, sel.value); if (command == COMMAND_GET_SINK_INFO || command == COMMAND_GET_SOURCE_INFO) { - if ((sel.value == NULL && (sel.id == SPA_ID_INVALID || sel.id == 0)) || - (sel.value != NULL && (spa_streq(sel.value, def) || spa_streq(sel.value, "0")))) - sel.value = get_default(client, command == COMMAND_GET_SINK_INFO); + o = find_device(client, sel.id, sel.value, + command == COMMAND_GET_SINK_INFO, NULL); } else { if (sel.value == NULL && sel.id == SPA_ID_INVALID) goto error_invalid; + o = select_object(manager, &sel); } - - if (command == COMMAND_GET_SOURCE_INFO) { - if (sel.value != NULL && spa_strendswith(sel.value, ".monitor")) - sel.value = strndupa(sel.value, strlen(sel.value)-8); - if (sel.id & MONITOR_FLAG) - sel.id &= INDEX_MASK; - } - - o = select_object(manager, &sel); if (o == NULL) goto error_noentity;