[pulseaudio-discuss] [RFC v1 5/6] bluetooth: Use profile availability to auto-switch profiles

Tanu Kaskinen tanuk at iki.fi
Mon Feb 18 08:03:24 PST 2013


On Mon, 2013-02-18 at 09:10 +0100, Mikel Astiz wrote:
> @@ -188,35 +170,48 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
>          return PA_HOOK_OK;
>  
>      /* Do not automatically switch profiles for headsets, just in case */
> -    if (pa_hashmap_get(port->profiles, "hsp") || pa_hashmap_get(port->profiles, "a2dp"))
> +    if (pa_streq(profile->name, "hsp") || pa_streq(profile->name, "a2dp"))
>          return PA_HOOK_OK;
>  
> -    is_active_profile = card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
> +    is_active_profile = card->active_profile == profile;
>  
> -    if (is_active_profile && port->available == PA_AVAILABLE_YES)
> -        return PA_HOOK_OK;
> +    if (profile->available == PA_AVAILABLE_YES) {
> +        if (is_active_profile)
> +            return PA_HOOK_OK;
>  
> -    if (!is_active_profile && port->available != PA_AVAILABLE_YES)
> -        return PA_HOOK_OK;
> +        if (card->active_profile && card->active_profile->available == PA_AVAILABLE_YES &&

I removed the card->active_profile check, because it's never NULL.

-- 
Tanu



More information about the pulseaudio-discuss mailing list