mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	sink, source: Call sink input suspend callback also on suspend cause change
Currently, virtual sinks and sources are not suspended when the master sink or source is suspended. To implement this, the slave must be able to track the suspend cause of the master. With this patch, the sink input suspend callback will not only be called when the sink or source is changing state, but also when the suspend cause changes. Similar to the set_state_in_*_thread_cb() functions, the suspend callback receives a state and a suspend cause as additional arguments. Because the new state and suspend cause of the sink or source have already been set, the old values are passed to the callback.
This commit is contained in:
		
							parent
							
								
									f7b3537bbf
								
							
						
					
					
						commit
						acb02d9e88
					
				
					 6 changed files with 54 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -400,6 +400,8 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t
 | 
			
		|||
    bool suspend_cause_changed;
 | 
			
		||||
    bool suspending;
 | 
			
		||||
    bool resuming;
 | 
			
		||||
    pa_sink_state_t old_state;
 | 
			
		||||
    pa_suspend_cause_t old_suspend_cause;
 | 
			
		||||
 | 
			
		||||
    pa_assert(s);
 | 
			
		||||
    pa_assert_ctl_context();
 | 
			
		||||
| 
						 | 
				
			
			@ -469,6 +471,7 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    old_suspend_cause = s->suspend_cause;
 | 
			
		||||
    if (suspend_cause_changed) {
 | 
			
		||||
        char old_cause_buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE];
 | 
			
		||||
        char new_cause_buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE];
 | 
			
		||||
| 
						 | 
				
			
			@ -478,6 +481,7 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t
 | 
			
		|||
        s->suspend_cause = suspend_cause;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    old_state = s->state;
 | 
			
		||||
    if (state_changed) {
 | 
			
		||||
        pa_log_debug("%s: state: %s -> %s", s->name, pa_sink_state_to_string(s->state), pa_sink_state_to_string(state));
 | 
			
		||||
        s->state = state;
 | 
			
		||||
| 
						 | 
				
			
			@ -490,7 +494,7 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (suspending || resuming) {
 | 
			
		||||
    if (suspending || resuming || suspend_cause_changed) {
 | 
			
		||||
        pa_sink_input *i;
 | 
			
		||||
        uint32_t idx;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -501,7 +505,7 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t
 | 
			
		|||
                (i->flags & PA_SINK_INPUT_KILL_ON_SUSPEND))
 | 
			
		||||
                pa_sink_input_kill(i);
 | 
			
		||||
            else if (i->suspend)
 | 
			
		||||
                i->suspend(i, state == PA_SINK_SUSPENDED);
 | 
			
		||||
                i->suspend(i, old_state, old_suspend_cause);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ((suspending || resuming || suspend_cause_changed) && s->monitor_source && state != PA_SINK_UNLINKED)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue