mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
Merge branch 'for-upstream/do-not-switch-to-bluetooth-computers-on-connect' into 'master'
bluetooth: Reduce priority and do not automatically route audio to other computers See merge request pulseaudio/pulseaudio!644
This commit is contained in:
commit
5466e29b06
3 changed files with 36 additions and 0 deletions
|
|
@ -181,6 +181,7 @@ typedef enum pa_bluetooth_form_factor {
|
|||
PA_BLUETOOTH_FORM_FACTOR_CAR,
|
||||
PA_BLUETOOTH_FORM_FACTOR_HIFI,
|
||||
PA_BLUETOOTH_FORM_FACTOR_PHONE,
|
||||
PA_BLUETOOTH_FORM_FACTOR_COMPUTER,
|
||||
} pa_bluetooth_form_factor_t;
|
||||
|
||||
/* Run from main thread */
|
||||
|
|
@ -207,6 +208,8 @@ static pa_bluetooth_form_factor_t form_factor_from_class(uint32_t class_of_devic
|
|||
minor = (class_of_device >> 2) & 0x3F;
|
||||
|
||||
switch (major) {
|
||||
case 1:
|
||||
return PA_BLUETOOTH_FORM_FACTOR_COMPUTER;
|
||||
case 2:
|
||||
return PA_BLUETOOTH_FORM_FACTOR_PHONE;
|
||||
case 4:
|
||||
|
|
@ -247,6 +250,8 @@ static const char *form_factor_to_string(pa_bluetooth_form_factor_t ff) {
|
|||
return "hifi";
|
||||
case PA_BLUETOOTH_FORM_FACTOR_PHONE:
|
||||
return "phone";
|
||||
case PA_BLUETOOTH_FORM_FACTOR_COMPUTER:
|
||||
return "computer";
|
||||
}
|
||||
|
||||
pa_assert_not_reached();
|
||||
|
|
@ -2030,6 +2035,11 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
|
|||
input_type = output_type = PA_DEVICE_PORT_TYPE_PHONE;
|
||||
break;
|
||||
|
||||
case PA_BLUETOOTH_FORM_FACTOR_COMPUTER:
|
||||
name_prefix = "computer";
|
||||
input_description = output_description = _("Computer");
|
||||
break;
|
||||
|
||||
case PA_BLUETOOTH_FORM_FACTOR_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -3678,6 +3678,12 @@ unsigned pa_device_init_priority(pa_proplist *p) {
|
|||
priority += 500;
|
||||
else if (pa_streq(s, "portable"))
|
||||
priority += 450;
|
||||
else if (pa_streq(s, "computer"))
|
||||
/* computers get a lower-than-base priority */
|
||||
priority += 0;
|
||||
else
|
||||
/* default base priority */
|
||||
priority += 100;
|
||||
}
|
||||
|
||||
if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_BUS))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue