summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd@luon.net>2014-11-16 23:15:50 +0100
committerDavid Henningsson <david.henningsson@canonical.com>2014-11-17 13:00:22 +0100
commitd5fec4ca7af9241d0c2ae17df40d0fb1c18c74a0 (patch)
tree5d8c2d0ac3d1e7af9ba031359cdf03b757b311c7
parente9513b40dbe8d155c005f41d661309ca8f350b46 (diff)
Alsa: Correct port availability with multiple jacks
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.
-rw-r--r--src/modules/alsa/module-alsa-card.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index ed332e0e5..fc9a772fc 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);