pulse-server: use the name of the default sink

When setting a new default sink/source, use the name of the object
instead of the name used for selecting the sink/source. This makes
it possible to use the id to search for the device but still have
the device name in the metadata as is expected.

Fixes #1004
This commit is contained in:
Wim Taymans 2021-04-02 10:05:56 +02:00
parent 63e7a5c5d4
commit 8cf6da467f

View file

@ -4951,7 +4951,7 @@ static int do_set_default(struct client *client, uint32_t command, uint32_t tag,
struct impl *impl = client->impl; struct impl *impl = client->impl;
struct pw_manager *manager = client->manager; struct pw_manager *manager = client->manager;
struct pw_manager_object *o; struct pw_manager_object *o;
const char *name; const char *name, *str;
int res; int res;
bool sink = command == COMMAND_SET_DEFAULT_SINK; bool sink = command == COMMAND_SET_DEFAULT_SINK;
@ -4967,7 +4967,9 @@ static int do_set_default(struct client *client, uint32_t command, uint32_t tag,
return -ENOENT; return -ENOENT;
if (name != NULL) { if (name != NULL) {
if (pw_endswith(name, ".monitor")) if (o->props && (str = pw_properties_get(o->props, PW_KEY_NODE_NAME)) != NULL)
name = str;
else if (pw_endswith(name, ".monitor"))
name = strndupa(name, strlen(name)-8); name = strndupa(name, strlen(name)-8);
res = pw_manager_set_metadata(manager, client->metadata_default, res = pw_manager_set_metadata(manager, client->metadata_default,