mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	core, device-port: check availability when choosing the default device
It doesn't make sense to use a sink or source whose active port is unavailable, so let's take this into account when choosing the default sink and source.
This commit is contained in:
		
							parent
							
								
									6b34896130
								
							
						
					
					
						commit
						1c477fcb67
					
				
					 2 changed files with 24 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -266,6 +266,14 @@ static int compare_sinks(pa_sink *a, pa_sink *b) {
 | 
			
		|||
 | 
			
		||||
    core = a->core;
 | 
			
		||||
 | 
			
		||||
    /* Available sinks always beat unavailable sinks. */
 | 
			
		||||
    if (a->active_port && a->active_port->available == PA_AVAILABLE_NO
 | 
			
		||||
            && (!b->active_port || b->active_port->available != PA_AVAILABLE_NO))
 | 
			
		||||
        return -1;
 | 
			
		||||
    if (b->active_port && b->active_port->available == PA_AVAILABLE_NO
 | 
			
		||||
            && (!a->active_port || a->active_port->available != PA_AVAILABLE_NO))
 | 
			
		||||
        return 1;
 | 
			
		||||
 | 
			
		||||
    /* The configured default sink is preferred over any other sink. */
 | 
			
		||||
    if (b == core->configured_default_sink)
 | 
			
		||||
        return -1;
 | 
			
		||||
| 
						 | 
				
			
			@ -332,6 +340,14 @@ static int compare_sources(pa_source *a, pa_source *b) {
 | 
			
		|||
 | 
			
		||||
    core = a->core;
 | 
			
		||||
 | 
			
		||||
    /* Available sources always beat unavailable sources. */
 | 
			
		||||
    if (a->active_port && a->active_port->available == PA_AVAILABLE_NO
 | 
			
		||||
            && (!b->active_port || b->active_port->available != PA_AVAILABLE_NO))
 | 
			
		||||
        return -1;
 | 
			
		||||
    if (b->active_port && b->active_port->available == PA_AVAILABLE_NO
 | 
			
		||||
            && (!a->active_port || a->active_port->available != PA_AVAILABLE_NO))
 | 
			
		||||
        return 1;
 | 
			
		||||
 | 
			
		||||
    /* The configured default source is preferred over any other source. */
 | 
			
		||||
    if (b == core->configured_default_source)
 | 
			
		||||
        return -1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue