mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	fix a race condition with stream connection vs. latency measuremtn (found by theBear)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1355 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									6e3de3dbe5
								
							
						
					
					
						commit
						97202d1b2d
					
				
					 1 changed files with 19 additions and 17 deletions
				
			
		| 
						 | 
					@ -490,8 +490,21 @@ static void start_subscribe(struct userdata *u) {
 | 
				
			||||||
    pa_pstream_send_tagstruct(u->pstream, t);
 | 
					    pa_pstream_send_tagstruct(u->pstream, t);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
 | 
				
			||||||
 | 
					    struct userdata *u = userdata;
 | 
				
			||||||
 | 
					    struct timeval ntv;
 | 
				
			||||||
 | 
					    assert(m && e && u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    request_latency(u);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    pa_gettimeofday(&ntv);
 | 
				
			||||||
 | 
					    ntv.tv_sec += LATENCY_INTERVAL;
 | 
				
			||||||
 | 
					    m->time_restart(e, &ntv);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
 | 
					static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
 | 
				
			||||||
    struct userdata *u = userdata;
 | 
					    struct userdata *u = userdata;
 | 
				
			||||||
 | 
					    struct timeval ntv;
 | 
				
			||||||
    assert(pd && u && u->pdispatch == pd);
 | 
					    assert(pd && u && u->pdispatch == pd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (command != PA_COMMAND_REPLY) {
 | 
					    if (command != PA_COMMAND_REPLY) {
 | 
				
			||||||
| 
						 | 
					@ -535,6 +548,11 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN
 | 
				
			||||||
    start_subscribe(u);
 | 
					    start_subscribe(u);
 | 
				
			||||||
    request_info(u);
 | 
					    request_info(u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert(!u->time_event);
 | 
				
			||||||
 | 
					    pa_gettimeofday(&ntv);
 | 
				
			||||||
 | 
					    ntv.tv_sec += LATENCY_INTERVAL;
 | 
				
			||||||
 | 
					    u->time_event = u->core->mainloop->time_new(u->core->mainloop, &ntv, timeout_callback, u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    request_latency(u);
 | 
					    request_latency(u);
 | 
				
			||||||
#ifdef TUNNEL_SINK
 | 
					#ifdef TUNNEL_SINK
 | 
				
			||||||
    send_bytes(u);
 | 
					    send_bytes(u);
 | 
				
			||||||
| 
						 | 
					@ -840,18 +858,6 @@ static int source_set_hw_mute(pa_source *source) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
 | 
					 | 
				
			||||||
    struct userdata *u = userdata;
 | 
					 | 
				
			||||||
    struct timeval ntv;
 | 
					 | 
				
			||||||
    assert(m && e && u);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    request_latency(u);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    pa_gettimeofday(&ntv);
 | 
					 | 
				
			||||||
    ntv.tv_sec += LATENCY_INTERVAL;
 | 
					 | 
				
			||||||
    m->time_restart(e, &ntv);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int load_key(struct userdata *u, const char*fn) {
 | 
					static int load_key(struct userdata *u, const char*fn) {
 | 
				
			||||||
    assert(u);
 | 
					    assert(u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -883,10 +889,8 @@ int pa__init(pa_core *c, pa_module*m) {
 | 
				
			||||||
    struct userdata *u = NULL;
 | 
					    struct userdata *u = NULL;
 | 
				
			||||||
    pa_sample_spec ss;
 | 
					    pa_sample_spec ss;
 | 
				
			||||||
    pa_channel_map map;
 | 
					    pa_channel_map map;
 | 
				
			||||||
    struct timeval ntv;
 | 
					 | 
				
			||||||
    char *t, *dn = NULL;
 | 
					    char *t, *dn = NULL;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    assert(c && m);
 | 
					    assert(c && m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
 | 
					    if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
 | 
				
			||||||
| 
						 | 
					@ -986,9 +990,7 @@ int pa__init(pa_core *c, pa_module*m) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    pa_xfree(dn);
 | 
					    pa_xfree(dn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_gettimeofday(&ntv);
 | 
					    u->time_event = NULL;
 | 
				
			||||||
    ntv.tv_sec += LATENCY_INTERVAL;
 | 
					 | 
				
			||||||
    u->time_event = c->mainloop->time_new(c->mainloop, &ntv, timeout_callback, u);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_modargs_free(ma);
 | 
					    pa_modargs_free(ma);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue