mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: improve lookup of default source and sink
Make things work then there is no default input device and the default source is actually the monitor of the default sink. Also implement lookups of monitor sources with the monitor id as the name. Fixes #1691
This commit is contained in:
parent
1b09640b6f
commit
f1c29194a8
1 changed files with 40 additions and 26 deletions
|
|
@ -2168,49 +2168,63 @@ static struct pw_manager_object *find_device(struct client *client,
|
||||||
uint32_t id, const char *name, bool sink, bool *is_monitor)
|
uint32_t id, const char *name, bool sink, bool *is_monitor)
|
||||||
{
|
{
|
||||||
struct selector sel;
|
struct selector sel;
|
||||||
const char *def;
|
bool monitor = false, find_default = false;
|
||||||
bool monitor = false;
|
|
||||||
|
|
||||||
if (id == 0)
|
pw_log_info("name:%s id:%u", name, id);
|
||||||
id = SPA_ID_INVALID;
|
|
||||||
|
|
||||||
if (name != NULL && !sink) {
|
if (name != NULL) {
|
||||||
if (spa_strendswith(name, ".monitor")) {
|
if (spa_streq(name, DEFAULT_MONITOR)) {
|
||||||
name = strndupa(name, strlen(name)-8);
|
if (sink)
|
||||||
monitor = true;
|
return NULL;
|
||||||
} else if (spa_streq(name, DEFAULT_MONITOR)) {
|
sink = true;
|
||||||
|
find_default = true;
|
||||||
|
} else if (spa_streq(name, DEFAULT_SOURCE)) {
|
||||||
|
if (sink)
|
||||||
|
return NULL;
|
||||||
|
find_default = true;
|
||||||
|
} else if (spa_streq(name, DEFAULT_SINK)) {
|
||||||
|
if (!sink)
|
||||||
|
return NULL;
|
||||||
|
find_default = true;
|
||||||
|
} else if (spa_atou32(name, &id, 0)) {
|
||||||
name = NULL;
|
name = NULL;
|
||||||
monitor = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (id != SPA_ID_INVALID && !sink) {
|
if (name == NULL && (id == SPA_ID_INVALID || id == 0))
|
||||||
|
find_default = true;
|
||||||
|
|
||||||
|
if (find_default) {
|
||||||
|
name = get_default(client, sink);
|
||||||
|
id = SPA_ID_INVALID;
|
||||||
|
}
|
||||||
|
pw_log_info("name:%s id:%u", name, id);
|
||||||
|
|
||||||
|
if (id != SPA_ID_INVALID) {
|
||||||
if (id & MONITOR_FLAG) {
|
if (id & MONITOR_FLAG) {
|
||||||
|
if (sink)
|
||||||
|
return NULL;
|
||||||
monitor = true;
|
monitor = true;
|
||||||
id &= ~MONITOR_FLAG;
|
id &= ~MONITOR_FLAG;
|
||||||
}
|
}
|
||||||
|
} else if (name != NULL) {
|
||||||
|
if (spa_strendswith(name, ".monitor")) {
|
||||||
|
name = strndupa(name, strlen(name)-8);
|
||||||
|
monitor = true;
|
||||||
}
|
}
|
||||||
if (monitor)
|
} else
|
||||||
sink = true;
|
return NULL;
|
||||||
|
|
||||||
if (is_monitor)
|
if (is_monitor)
|
||||||
*is_monitor = monitor;
|
*is_monitor = monitor;
|
||||||
|
|
||||||
spa_zero(sel);
|
spa_zero(sel);
|
||||||
|
sel.type = sink ?
|
||||||
|
pw_manager_object_is_sink :
|
||||||
|
pw_manager_object_is_source_or_monitor;
|
||||||
sel.id = id;
|
sel.id = id;
|
||||||
sel.key = PW_KEY_NODE_NAME;
|
sel.key = PW_KEY_NODE_NAME;
|
||||||
sel.value = name;
|
sel.value = name;
|
||||||
|
|
||||||
if (sink) {
|
|
||||||
sel.type = pw_manager_object_is_sink;
|
|
||||||
def = DEFAULT_SINK;
|
|
||||||
} else {
|
|
||||||
sel.type = pw_manager_object_is_source;
|
|
||||||
def = DEFAULT_SOURCE;
|
|
||||||
}
|
|
||||||
if (id == SPA_ID_INVALID &&
|
|
||||||
(sel.value == NULL || spa_streq(sel.value, def) ||
|
|
||||||
spa_streq(sel.value, "0")))
|
|
||||||
sel.value = get_default(client, sink);
|
|
||||||
|
|
||||||
return select_object(client->manager, &sel);
|
return select_object(client->manager, &sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue