mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse: use metadata to store default source/sink
The metadata is implemented by the session manager and it can decide what to do when the defaults change. It can also choose to save (some of) the metadata to a database. The metadata is also shared between applications so that changes can be picked up immediately.
This commit is contained in:
parent
2991a814cd
commit
ee54cb96aa
5 changed files with 232 additions and 11 deletions
|
|
@ -1247,13 +1247,25 @@ struct server_data {
|
|||
static const char *get_default_name(pa_context *c, uint32_t mask)
|
||||
{
|
||||
struct global *g;
|
||||
const char *str;
|
||||
const char *str, *name = NULL, *type, *key;
|
||||
|
||||
if (c->metadata) {
|
||||
if (mask & PA_SUBSCRIPTION_MASK_SINK)
|
||||
key = "http://pipewire.org/metadata/default-audio-sink";
|
||||
else if (mask & PA_SUBSCRIPTION_MASK_SOURCE)
|
||||
key = "http://pipewire.org/metadata/default-audio-source";
|
||||
else
|
||||
return NULL;
|
||||
|
||||
if (pa_metadata_get(c->metadata, PW_ID_CORE, key, &type, &name) <= 0)
|
||||
name = NULL;
|
||||
}
|
||||
spa_list_for_each(g, &c->globals, link) {
|
||||
if ((g->mask & mask) != mask)
|
||||
continue;
|
||||
if (g->props != NULL &&
|
||||
(str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) != NULL)
|
||||
(str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) != NULL &&
|
||||
(name == NULL || strcmp(name, str) == 0))
|
||||
return str;
|
||||
}
|
||||
return "unknown";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue