[pulseaudio-discuss] [PATCH 1/4] Alsa: Correct port availability with multiple jacks
David Henningsson
david.henningsson at canonical.com
Mon Nov 17 04:07:07 PST 2014
On 2014-11-16 23:15, 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 if the first one 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 more precise states (yes/no) over unknown and yes
> over others. However in case a plugged jack makes the port unavailable
> let that overrule everything else.
This makes sense. Pushed now, thanks.
> ---
> src/modules/alsa/module-alsa-card.c | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
> index ed332e0..fc9a772 100644
> --- a/src/modules/alsa/module-alsa-card.c
> +++ b/src/modules/alsa/module-alsa-card.c
> @@ -335,15 +335,26 @@ 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) {
> + /* If a plugged-in jack causes the availability to go to NO, it
> + * should override all other availability information (like a
> + * blacklist) so set and bail */
> + if (jack->plugged_in) {
> + pa = cpa;
> + break;
> + }
>
> - 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
> + /* If the current availablility is unknown go the more precise no,
> + * but otherwise don't change state */
> + if (pa == PA_AVAILABLE_UNKNOWN)
> pa = cpa;
> + } else if (cpa == PA_AVAILABLE_YES) {
> + /* Output is available through at least one jack, so go to that
> + * level of availability. We still need to continue iterating through
> + * the jacks in case a jack is plugged in that forces the state to no
> + */
> + pa = cpa;
> + }
> }
>
> pa_device_port_set_available(p, pa);
>
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
More information about the pulseaudio-discuss
mailing list