From dbebbe2f3327d019b82d9f3b5770755d7d9b3a43 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 6 Mar 2021 19:58:52 +0100 Subject: [PATCH] pulse-server: support NULL set-default-sink/source It is allowed to set a NULL value for the default source/sink, which then simply clears any configured value. --- .../module-protocol-pulse/pulse-server.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 0c1167f8e..8d259b323 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -4847,13 +4847,20 @@ static int do_set_default(struct client *client, uint32_t command, uint32_t tag, pw_log_info(NAME" %p: [%s] %s tag:%u name:%s", impl, client->name, commands[command].name, tag, name); - if ((o = find_device(client, SPA_ID_INVALID, name, sink)) == NULL) - return -ENOENT; - - if ((res = pw_manager_set_metadata(manager, client->metadata_default, - PW_ID_CORE, - sink ? METADATA_CONFIG_DEFAULT_SINK : METADATA_CONFIG_DEFAULT_SOURCE, - "Spa:String:JSON", "{ \"name\": \"%s\" }", name)) < 0) + if (name != NULL) { + if ((o = find_device(client, SPA_ID_INVALID, name, sink)) == NULL) + return -ENOENT; + res = pw_manager_set_metadata(manager, client->metadata_default, + PW_ID_CORE, + sink ? METADATA_CONFIG_DEFAULT_SINK : METADATA_CONFIG_DEFAULT_SOURCE, + "Spa:String:JSON", "{ \"name\": \"%s\" }", name); + } else { + res = pw_manager_set_metadata(manager, client->metadata_default, + PW_ID_CORE, + sink ? METADATA_CONFIG_DEFAULT_SINK : METADATA_CONFIG_DEFAULT_SOURCE, + NULL, NULL); + } + if (res < 0) return res; return reply_simple_ack(client, tag);