[pulseaudio-discuss] [PATCH] sink/source: lower priority of phone sinks/sources

Tanu Kaskinen tanuk at iki.fi
Sat Sep 2 11:12:55 UTC 2017


On Fri, 2017-09-01 at 16:21 +0200, Georg Chini wrote:
> When a phone is connected via bluetooth and switches to HFP, the sinks
> and sources will have higher priority than the built-in devices.
> Therefore they are chosen as default and module-bluetooth-policy will
> incorrectly insert loopback modules that loop the phone back to itself.
> 
> This patch fixes the problem by lowering the priority of devices with
> the form factor "phone" so that they are never chosen as default sink
> or source unless no other sound device is available.
> ---
>  src/pulsecore/sink.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
> index a8b4cd3d..e1bd5a08 100644
> --- a/src/pulsecore/sink.c
> +++ b/src/pulsecore/sink.c
> @@ -3529,6 +3529,8 @@ unsigned pa_device_init_priority(pa_proplist *p) {
>              priority += 450;
>          else if (pa_streq(s, "internal"))
>              priority += 400;
> +        else if (pa_streq(s, "phone"))
> +            priority -= 1000;
>      }
>  
>      if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_BUS))) {

priority is unsigned, and its value is not guaranteed to be high enough
for substracting 1000 from it.

Maybe it would make sense to just immediately return 0 if we spot a
phone form factor?

-- 
Tanu

https://www.patreon.com/tanuk


More information about the pulseaudio-discuss mailing list