mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	sink-input: remove the DRAINED state
The only thing that the drained state was being used for was "pacmd list-sink-inputs". In all other cases the drained and running states were treated as equivalent. IMHO, this usage doesn't justify the complexity that the additional state brings. This patch was inspired by a bug report[1] that pointed out an error in an if condition in pa_sink_input_set_state_within_thread(). The buggy code is now removed altogether. [1] https://bugs.freedesktop.org/show_bug.cgi?id=106982
This commit is contained in:
		
							parent
							
								
									e40adfa9cc
								
							
						
					
					
						commit
						64ba239f65
					
				
					 4 changed files with 3 additions and 23 deletions
				
			
		| 
						 | 
					@ -222,7 +222,7 @@ static pa_hook_result_t sink_input_move_finish_hook_cb(pa_core *c, pa_sink_input
 | 
				
			||||||
    pa_assert(u);
 | 
					    pa_assert(u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    state = pa_sink_input_get_state(s);
 | 
					    state = pa_sink_input_get_state(s);
 | 
				
			||||||
    if (state != PA_SINK_INPUT_RUNNING && state != PA_SINK_INPUT_DRAINED)
 | 
					    if (state != PA_SINK_INPUT_RUNNING)
 | 
				
			||||||
        return PA_HOOK_OK;
 | 
					        return PA_HOOK_OK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((d = pa_hashmap_get(u->device_infos, s->sink)))
 | 
					    if ((d = pa_hashmap_get(u->device_infos, s->sink)))
 | 
				
			||||||
| 
						 | 
					@ -282,7 +282,7 @@ static pa_hook_result_t sink_input_state_changed_hook_cb(pa_core *c, pa_sink_inp
 | 
				
			||||||
    pa_assert(u);
 | 
					    pa_assert(u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    state = pa_sink_input_get_state(s);
 | 
					    state = pa_sink_input_get_state(s);
 | 
				
			||||||
    if ((state == PA_SINK_INPUT_RUNNING || state == PA_SINK_INPUT_DRAINED) && s->sink)
 | 
					    if (state == PA_SINK_INPUT_RUNNING && s->sink)
 | 
				
			||||||
        if ((d = pa_hashmap_get(u->device_infos, s->sink)))
 | 
					        if ((d = pa_hashmap_get(u->device_infos, s->sink)))
 | 
				
			||||||
            resume(d);
 | 
					            resume(d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -525,7 +525,6 @@ char *pa_sink_input_list_to_string(pa_core *c) {
 | 
				
			||||||
    static const char* const state_table[] = {
 | 
					    static const char* const state_table[] = {
 | 
				
			||||||
        [PA_SINK_INPUT_INIT] = "INIT",
 | 
					        [PA_SINK_INPUT_INIT] = "INIT",
 | 
				
			||||||
        [PA_SINK_INPUT_RUNNING] = "RUNNING",
 | 
					        [PA_SINK_INPUT_RUNNING] = "RUNNING",
 | 
				
			||||||
        [PA_SINK_INPUT_DRAINED] = "DRAINED",
 | 
					 | 
				
			||||||
        [PA_SINK_INPUT_CORKED] = "CORKED",
 | 
					        [PA_SINK_INPUT_CORKED] = "CORKED",
 | 
				
			||||||
        [PA_SINK_INPUT_UNLINKED] = "UNLINKED"
 | 
					        [PA_SINK_INPUT_UNLINKED] = "UNLINKED"
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -541,7 +541,6 @@ int pa_sink_input_new(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    i->thread_info.state = i->state;
 | 
					    i->thread_info.state = i->state;
 | 
				
			||||||
    i->thread_info.attached = false;
 | 
					    i->thread_info.attached = false;
 | 
				
			||||||
    pa_atomic_store(&i->thread_info.drained, 1);
 | 
					 | 
				
			||||||
    i->thread_info.sample_spec = i->sample_spec;
 | 
					    i->thread_info.sample_spec = i->sample_spec;
 | 
				
			||||||
    i->thread_info.resampler = resampler;
 | 
					    i->thread_info.resampler = resampler;
 | 
				
			||||||
    i->thread_info.soft_volume = i->soft_volume;
 | 
					    i->thread_info.soft_volume = i->soft_volume;
 | 
				
			||||||
| 
						 | 
					@ -610,9 +609,6 @@ static void sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state)
 | 
				
			||||||
    pa_assert(i);
 | 
					    pa_assert(i);
 | 
				
			||||||
    pa_assert_ctl_context();
 | 
					    pa_assert_ctl_context();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (state == PA_SINK_INPUT_DRAINED)
 | 
					 | 
				
			||||||
        state = PA_SINK_INPUT_RUNNING;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (i->state == state)
 | 
					    if (i->state == state)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -924,7 +920,6 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* OK, we're corked or the implementor didn't give us any
 | 
					            /* OK, we're corked or the implementor didn't give us any
 | 
				
			||||||
             * data, so let's just hand out silence */
 | 
					             * data, so let's just hand out silence */
 | 
				
			||||||
            pa_atomic_store(&i->thread_info.drained, 1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            pa_memblockq_seek(i->thread_info.render_memblockq, (int64_t) slength, PA_SEEK_RELATIVE, true);
 | 
					            pa_memblockq_seek(i->thread_info.render_memblockq, (int64_t) slength, PA_SEEK_RELATIVE, true);
 | 
				
			||||||
            i->thread_info.playing_for = 0;
 | 
					            i->thread_info.playing_for = 0;
 | 
				
			||||||
| 
						 | 
					@ -935,8 +930,6 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_atomic_store(&i->thread_info.drained, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        pa_assert(tchunk.length > 0);
 | 
					        pa_assert(tchunk.length > 0);
 | 
				
			||||||
        pa_assert(tchunk.memblock);
 | 
					        pa_assert(tchunk.memblock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2013,10 +2006,6 @@ void pa_sink_input_set_state_within_thread(pa_sink_input *i, pa_sink_input_state
 | 
				
			||||||
    if (state == i->thread_info.state)
 | 
					    if (state == i->thread_info.state)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((state == PA_SINK_INPUT_DRAINED || state == PA_SINK_INPUT_RUNNING) &&
 | 
					 | 
				
			||||||
        !(i->thread_info.state == PA_SINK_INPUT_DRAINED || i->thread_info.state != PA_SINK_INPUT_RUNNING))
 | 
					 | 
				
			||||||
        pa_atomic_store(&i->thread_info.drained, 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    corking = state == PA_SINK_INPUT_CORKED && i->thread_info.state == PA_SINK_INPUT_RUNNING;
 | 
					    corking = state == PA_SINK_INPUT_CORKED && i->thread_info.state == PA_SINK_INPUT_RUNNING;
 | 
				
			||||||
    uncorking = i->thread_info.state == PA_SINK_INPUT_CORKED && state == PA_SINK_INPUT_RUNNING;
 | 
					    uncorking = i->thread_info.state == PA_SINK_INPUT_CORKED && state == PA_SINK_INPUT_RUNNING;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2129,9 +2118,6 @@ pa_sink_input_state_t pa_sink_input_get_state(pa_sink_input *i) {
 | 
				
			||||||
    pa_sink_input_assert_ref(i);
 | 
					    pa_sink_input_assert_ref(i);
 | 
				
			||||||
    pa_assert_ctl_context();
 | 
					    pa_assert_ctl_context();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (i->state == PA_SINK_INPUT_RUNNING || i->state == PA_SINK_INPUT_DRAINED)
 | 
					 | 
				
			||||||
        return pa_atomic_load(&i->thread_info.drained) ? PA_SINK_INPUT_DRAINED : PA_SINK_INPUT_RUNNING;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return i->state;
 | 
					    return i->state;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef enum pa_sink_input_state {
 | 
					typedef enum pa_sink_input_state {
 | 
				
			||||||
    PA_SINK_INPUT_INIT,         /*< The stream is not active yet, because pa_sink_input_put() has not been called yet */
 | 
					    PA_SINK_INPUT_INIT,         /*< The stream is not active yet, because pa_sink_input_put() has not been called yet */
 | 
				
			||||||
    PA_SINK_INPUT_DRAINED,      /*< The stream stopped playing because there was no data to play */
 | 
					 | 
				
			||||||
    PA_SINK_INPUT_RUNNING,      /*< The stream is alive and kicking */
 | 
					    PA_SINK_INPUT_RUNNING,      /*< The stream is alive and kicking */
 | 
				
			||||||
    PA_SINK_INPUT_CORKED,       /*< The stream was corked on user request */
 | 
					    PA_SINK_INPUT_CORKED,       /*< The stream was corked on user request */
 | 
				
			||||||
    PA_SINK_INPUT_UNLINKED      /*< The stream is dead */
 | 
					    PA_SINK_INPUT_UNLINKED      /*< The stream is dead */
 | 
				
			||||||
| 
						 | 
					@ -43,7 +42,7 @@ typedef enum pa_sink_input_state {
 | 
				
			||||||
} pa_sink_input_state_t;
 | 
					} pa_sink_input_state_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline bool PA_SINK_INPUT_IS_LINKED(pa_sink_input_state_t x) {
 | 
					static inline bool PA_SINK_INPUT_IS_LINKED(pa_sink_input_state_t x) {
 | 
				
			||||||
    return x == PA_SINK_INPUT_DRAINED || x == PA_SINK_INPUT_RUNNING || x == PA_SINK_INPUT_CORKED;
 | 
					    return x == PA_SINK_INPUT_RUNNING || x == PA_SINK_INPUT_CORKED;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef enum pa_sink_input_flags {
 | 
					typedef enum pa_sink_input_flags {
 | 
				
			||||||
| 
						 | 
					@ -67,9 +66,6 @@ struct pa_sink_input {
 | 
				
			||||||
    uint32_t index;
 | 
					    uint32_t index;
 | 
				
			||||||
    pa_core *core;
 | 
					    pa_core *core;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Please note that this state should only be read with
 | 
					 | 
				
			||||||
     * pa_sink_input_get_state(). That function will transparently
 | 
					 | 
				
			||||||
     * merge the thread_info.drained value in. */
 | 
					 | 
				
			||||||
    pa_sink_input_state_t state;
 | 
					    pa_sink_input_state_t state;
 | 
				
			||||||
    pa_sink_input_flags_t flags;
 | 
					    pa_sink_input_flags_t flags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -231,7 +227,6 @@ struct pa_sink_input {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    struct {
 | 
					    struct {
 | 
				
			||||||
        pa_sink_input_state_t state;
 | 
					        pa_sink_input_state_t state;
 | 
				
			||||||
        pa_atomic_t drained;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_cvolume soft_volume;
 | 
					        pa_cvolume soft_volume;
 | 
				
			||||||
        bool muted:1;
 | 
					        bool muted:1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue