switch-on-connect: Don't switch to Bluetooth computers

Do not automatically switch if the bluetooth card represets a remote
device with a computer form-factor.

If the user is connecting two computers over Bluetooth they most likely
want to use a non-audio feature like file transfer or network sharing.
Automatic audio switching in these cases creates a very poor user
experience. If the user actually wants to stream audio they can manually
select the Bluetooth audio sink or source.
This commit is contained in:
João Paulo Rechi Vita 2019-05-21 20:28:49 -07:00 committed by João Paulo Rechi Vita
parent da243cf1c7
commit b819942968

View file

@ -92,6 +92,16 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void*
return PA_HOOK_OK;
}
/* Don't switch to computers implementing Bluetooth audio profiles */
s = pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_BUS);
if (pa_safe_streq(s, "bluetooth")) {
s = pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_FORM_FACTOR);
if (pa_safe_streq(s, "computer")) {
pa_log_debug("Refusing to switch to Bluetooth sink on a computer");
return PA_HOOK_OK;
}
}
/* Ignore virtual sinks if not configured otherwise on the command line */
if (u->ignore_virtual && !(sink->flags & PA_SINK_HARDWARE)) {
pa_log_debug("Refusing to switch to virtual sink");
@ -152,6 +162,16 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
return PA_HOOK_OK;
}
/* Don't switch to computers implementing Bluetooth audio profiles */
s = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_BUS);
if (pa_safe_streq(s, "bluetooth")) {
s = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_FORM_FACTOR);
if (pa_safe_streq(s, "computer")) {
pa_log_debug("Refusing to switch to Bluetooth source on a computer");
return PA_HOOK_OK;
}
}
/* Ignore virtual sources if not configured otherwise on the command line */
if (u->ignore_virtual && !(source->flags & PA_SOURCE_HARDWARE)) {
pa_log_debug("Refusing to switch to virtual source");