[pulseaudio-discuss] [PATCH] Alsa: Correct port availability with multiple jacks

David Henningsson david.henningsson at canonical.com
Mon Oct 27 21:30:01 PDT 2014



On 2014-10-24 22:33, Sjoerd Simons wrote:
> In case there are two independent jacks for one port (e.g. Dock
> Headphone Jack and Headphone Jack), the availability ends up being
> incorrect for one of the first was _NO (not plugged) and the second gets
> _YES (plugged). Also pulse complains about the state being inconsistent
> which isn't true.
>
> Fix this by preferring higher states (_YES > _NO > _UNKNOWN)

Thanks, I agree with this conclusion. I didn't really know what to do 
with one jack being yes and another being no, but the above reasoning 
makes sense.

I'm not sure I'm happy with just a simple ">" comparison - in case we 
add more jack states in the future, they might not fit with the ">" 
scheme. But maybe we should deal with that when the problem comes and 
just take your patch as-is now. What do other people think?

> ---
>   src/modules/alsa/module-alsa-card.c | 10 ++--------
>   1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
> index ed332e0..0026e0f 100644
> --- a/src/modules/alsa/module-alsa-card.c
> +++ b/src/modules/alsa/module-alsa-card.c
> @@ -335,14 +335,8 @@ static void report_port_state(pa_device_port *p, struct userdata *u) {
>
>           cpa = jack->plugged_in ? jack->state_plugged : jack->state_unplugged;
>
> -        /* "Yes" and "no" trumphs "unknown" if we have more than one jack */
> -        if (cpa == PA_AVAILABLE_UNKNOWN)
> -            continue;
> -
> -        if ((cpa == PA_AVAILABLE_NO && pa == PA_AVAILABLE_YES) ||
> -            (pa == PA_AVAILABLE_NO && cpa == PA_AVAILABLE_YES))
> -            pa_log_warn("Availability of port '%s' is inconsistent!", p->name);
> -        else
> +        /* Prefer going towards _YES in case of multiple jacks */
> +        if (cpa > pa)
>               pa = cpa;
>       }
>
>

-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


More information about the pulseaudio-discuss mailing list