mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									e9513b40db
								
							
						
					
					
						commit
						d5fec4ca7a
					
				
					 1 changed files with 19 additions and 8 deletions
				
			
		| 
						 | 
					@ -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;
 | 
					        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_NO) {
 | 
				
			||||||
        if (cpa == PA_AVAILABLE_UNKNOWN)
 | 
					          /* If a plugged-in jack causes the availability to go to NO, it
 | 
				
			||||||
            continue;
 | 
					           * should override all other availability information (like a
 | 
				
			||||||
 | 
					           * blacklist) so set and bail */
 | 
				
			||||||
        if ((cpa == PA_AVAILABLE_NO && pa == PA_AVAILABLE_YES) ||
 | 
					          if (jack->plugged_in) {
 | 
				
			||||||
            (pa == PA_AVAILABLE_NO && cpa == PA_AVAILABLE_YES))
 | 
					 | 
				
			||||||
            pa_log_warn("Availability of port '%s' is inconsistent!", p->name);
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
            pa = cpa;
 | 
					            pa = cpa;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          /* 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);
 | 
					    pa_device_port_set_available(p, pa);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue