mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: improve device lookup
Make sure don't handle names ending in .monitor as a valid sink (because it's a monitor on the sink). Make sure we don't return a sink (monitor) as a source accidentally but only when explicitly requested by name with the .monitor extension. Makes pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -5% pactl set-source-volume alsa_output.pci-0000_00_1b.0.analog-stereo -5% fail as expected.
This commit is contained in:
parent
3f77c4e25f
commit
3a8894d2a4
1 changed files with 19 additions and 5 deletions
|
|
@ -2453,7 +2453,7 @@ static struct pw_manager_object *find_device(struct client *client,
|
|||
uint32_t index, const char *name, bool sink, bool *is_monitor)
|
||||
{
|
||||
struct selector sel;
|
||||
bool monitor = false, find_default = false;
|
||||
bool monitor = false, find_default = false, allow_monitor = false;
|
||||
struct pw_manager_object *o;
|
||||
|
||||
if (name != NULL) {
|
||||
|
|
@ -2463,10 +2463,12 @@ static struct pw_manager_object *find_device(struct client *client,
|
|||
sink = true;
|
||||
find_default = true;
|
||||
monitor = true;
|
||||
allow_monitor = true;
|
||||
} else if (spa_streq(name, DEFAULT_SOURCE)) {
|
||||
if (sink)
|
||||
return NULL;
|
||||
find_default = true;
|
||||
allow_monitor = true;
|
||||
} else if (spa_streq(name, DEFAULT_SINK)) {
|
||||
if (!sink)
|
||||
return NULL;
|
||||
|
|
@ -2485,8 +2487,10 @@ static struct pw_manager_object *find_device(struct client *client,
|
|||
|
||||
if (name != NULL) {
|
||||
if (spa_strendswith(name, ".monitor")) {
|
||||
if (!sink) {
|
||||
name = strndupa(name, strlen(name)-8);
|
||||
monitor = true;
|
||||
allow_monitor = true;
|
||||
}
|
||||
}
|
||||
} else if (index == SPA_ID_INVALID)
|
||||
return NULL;
|
||||
|
|
@ -2502,9 +2506,19 @@ static struct pw_manager_object *find_device(struct client *client,
|
|||
|
||||
o = select_object(client->manager, &sel);
|
||||
if (o != NULL) {
|
||||
if (!sink && pw_manager_object_is_monitor(o))
|
||||
if (!sink) {
|
||||
if (pw_manager_object_is_monitor(o)) {
|
||||
if (!allow_monitor)
|
||||
return NULL;
|
||||
monitor = true;
|
||||
}
|
||||
else if (!pw_manager_object_is_source(o))
|
||||
return NULL;
|
||||
} else {
|
||||
if (!pw_manager_object_is_sink(o))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (is_monitor)
|
||||
*is_monitor = monitor;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue