mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	simplify things and make sure timing setters can be called in most contexts
This commit is contained in:
		
							parent
							
								
									44ca897769
								
							
						
					
					
						commit
						892a83945e
					
				
					 2 changed files with 38 additions and 34 deletions
				
			
		| 
						 | 
					@ -1843,12 +1843,15 @@ void pa_sink_invalidate_requested_latency(pa_sink *s) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    s->thread_info.requested_latency_valid = FALSE;
 | 
					    s->thread_info.requested_latency_valid = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (s->update_requested_latency)
 | 
					    if (PA_SINK_IS_LINKED(s->thread_info.state)) {
 | 
				
			||||||
        s->update_requested_latency(s);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL)))
 | 
					        if (s->update_requested_latency)
 | 
				
			||||||
        if (i->update_sink_requested_latency)
 | 
					            s->update_requested_latency(s);
 | 
				
			||||||
            i->update_sink_requested_latency(i);
 | 
					
 | 
				
			||||||
 | 
					        while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL)))
 | 
				
			||||||
 | 
					            if (i->update_sink_requested_latency)
 | 
				
			||||||
 | 
					                i->update_sink_requested_latency(i);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Called from main thread */
 | 
					/* Called from main thread */
 | 
				
			||||||
| 
						 | 
					@ -1881,15 +1884,8 @@ void pa_sink_set_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_
 | 
				
			||||||
        r[1] = max_latency;
 | 
					        r[1] = max_latency;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_LATENCY_RANGE, r, 0, NULL) == 0);
 | 
					        pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_LATENCY_RANGE, r, 0, NULL) == 0);
 | 
				
			||||||
    } else {
 | 
					    } else
 | 
				
			||||||
        s->thread_info.min_latency = min_latency;
 | 
					        pa_sink_set_latency_range_within_thread(s, min_latency, max_latency);
 | 
				
			||||||
        s->thread_info.max_latency = max_latency;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        s->monitor_source->thread_info.min_latency = min_latency;
 | 
					 | 
				
			||||||
        s->monitor_source->thread_info.max_latency = max_latency;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        s->thread_info.requested_latency_valid = s->monitor_source->thread_info.requested_latency_valid = FALSE;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Called from main thread */
 | 
					/* Called from main thread */
 | 
				
			||||||
| 
						 | 
					@ -1913,7 +1909,6 @@ void pa_sink_get_latency_range(pa_sink *s, pa_usec_t *min_latency, pa_usec_t *ma
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Called from IO thread */
 | 
					/* Called from IO thread */
 | 
				
			||||||
void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency) {
 | 
					void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency) {
 | 
				
			||||||
    pa_sink_input *i;
 | 
					 | 
				
			||||||
    void *state = NULL;
 | 
					    void *state = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_sink_assert_ref(s);
 | 
					    pa_sink_assert_ref(s);
 | 
				
			||||||
| 
						 | 
					@ -1930,9 +1925,13 @@ void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency,
 | 
				
			||||||
    s->thread_info.min_latency = min_latency;
 | 
					    s->thread_info.min_latency = min_latency;
 | 
				
			||||||
    s->thread_info.max_latency = max_latency;
 | 
					    s->thread_info.max_latency = max_latency;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL)))
 | 
					    if (PA_SINK_IS_LINKED(s->thread_info.state)) {
 | 
				
			||||||
        if (i->update_sink_latency_range)
 | 
					        pa_sink_input *i;
 | 
				
			||||||
            i->update_sink_latency_range(i);
 | 
					
 | 
				
			||||||
 | 
					        while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL)))
 | 
				
			||||||
 | 
					            if (i->update_sink_latency_range)
 | 
				
			||||||
 | 
					                i->update_sink_latency_range(i);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_sink_invalidate_requested_latency(s);
 | 
					    pa_sink_invalidate_requested_latency(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1124,17 +1124,21 @@ void pa_source_invalidate_requested_latency(pa_source *s) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    s->thread_info.requested_latency_valid = FALSE;
 | 
					    s->thread_info.requested_latency_valid = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (s->update_requested_latency)
 | 
					    if (PA_SOURCE_IS_LINKED(s->thread_info.state)) {
 | 
				
			||||||
        s->update_requested_latency(s);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL)))
 | 
					        if (s->update_requested_latency)
 | 
				
			||||||
        if (o->update_source_requested_latency)
 | 
					            s->update_requested_latency(s);
 | 
				
			||||||
            o->update_source_requested_latency(o);
 | 
					
 | 
				
			||||||
 | 
					        while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL)))
 | 
				
			||||||
 | 
					            if (o->update_source_requested_latency)
 | 
				
			||||||
 | 
					                o->update_source_requested_latency(o);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (s->monitor_of)
 | 
					    if (s->monitor_of)
 | 
				
			||||||
        pa_sink_invalidate_requested_latency(s->monitor_of);
 | 
					        pa_sink_invalidate_requested_latency(s->monitor_of);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Called from main thread */
 | 
				
			||||||
void pa_source_set_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) {
 | 
					void pa_source_set_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) {
 | 
				
			||||||
    pa_source_assert_ref(s);
 | 
					    pa_source_assert_ref(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1164,14 +1168,11 @@ void pa_source_set_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t
 | 
				
			||||||
        r[1] = max_latency;
 | 
					        r[1] = max_latency;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_SET_LATENCY_RANGE, r, 0, NULL) == 0);
 | 
					        pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_SET_LATENCY_RANGE, r, 0, NULL) == 0);
 | 
				
			||||||
    } else {
 | 
					    } else
 | 
				
			||||||
        s->thread_info.min_latency = min_latency;
 | 
					        pa_source_set_latency_range_within_thread(s, min_latency, max_latency);
 | 
				
			||||||
        s->thread_info.max_latency = max_latency;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        s->thread_info.requested_latency_valid = FALSE;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Called from main thread */
 | 
				
			||||||
void pa_source_get_latency_range(pa_source *s, pa_usec_t *min_latency, pa_usec_t *max_latency) {
 | 
					void pa_source_get_latency_range(pa_source *s, pa_usec_t *min_latency, pa_usec_t *max_latency) {
 | 
				
			||||||
   pa_source_assert_ref(s);
 | 
					   pa_source_assert_ref(s);
 | 
				
			||||||
   pa_assert(min_latency);
 | 
					   pa_assert(min_latency);
 | 
				
			||||||
| 
						 | 
					@ -1190,9 +1191,8 @@ void pa_source_get_latency_range(pa_source *s, pa_usec_t *min_latency, pa_usec_t
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Called from IO thread */
 | 
					/* Called from IO thread, and from main thread before pa_sink_put() is called */
 | 
				
			||||||
void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) {
 | 
					void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) {
 | 
				
			||||||
    pa_source_output *o;
 | 
					 | 
				
			||||||
    void *state = NULL;
 | 
					    void *state = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_source_assert_ref(s);
 | 
					    pa_source_assert_ref(s);
 | 
				
			||||||
| 
						 | 
					@ -1209,13 +1209,18 @@ void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_laten
 | 
				
			||||||
    s->thread_info.min_latency = min_latency;
 | 
					    s->thread_info.min_latency = min_latency;
 | 
				
			||||||
    s->thread_info.max_latency = max_latency;
 | 
					    s->thread_info.max_latency = max_latency;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL)))
 | 
					    if (PA_SOURCE_IS_LINKED(s->thread_info.state)) {
 | 
				
			||||||
        if (o->update_source_latency_range)
 | 
					        pa_source_output *o;
 | 
				
			||||||
            o->update_source_latency_range(o);
 | 
					
 | 
				
			||||||
 | 
					        while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL)))
 | 
				
			||||||
 | 
					            if (o->update_source_latency_range)
 | 
				
			||||||
 | 
					                o->update_source_latency_range(o);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_source_invalidate_requested_latency(s);
 | 
					    pa_source_invalidate_requested_latency(s);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Called from main thread */
 | 
				
			||||||
size_t pa_source_get_max_rewind(pa_source *s) {
 | 
					size_t pa_source_get_max_rewind(pa_source *s) {
 | 
				
			||||||
    size_t r;
 | 
					    size_t r;
 | 
				
			||||||
    pa_source_assert_ref(s);
 | 
					    pa_source_assert_ref(s);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue