mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	Having constant deferred events isn't allowed and causes problems. Use timers
instead. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@757 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									4bb5822618
								
							
						
					
					
						commit
						6ae8511a66
					
				
					 2 changed files with 27 additions and 13 deletions
				
			
		| 
						 | 
					@ -79,8 +79,9 @@ int deny_severity = LOG_WARNING;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OS_IS_WIN32
 | 
					#ifdef OS_IS_WIN32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void message_cb(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
 | 
					static void message_cb(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
 | 
				
			||||||
    MSG msg;
 | 
					    MSG msg;
 | 
				
			||||||
 | 
					    struct timeval tvnext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
 | 
					    while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
 | 
				
			||||||
        if (msg.message == WM_QUIT)
 | 
					        if (msg.message == WM_QUIT)
 | 
				
			||||||
| 
						 | 
					@ -90,6 +91,9 @@ static void message_cb(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
 | 
				
			||||||
            DispatchMessage(&msg);
 | 
					            DispatchMessage(&msg);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_timeval_add(pa_gettimeofday(&tvnext), 100000);
 | 
				
			||||||
 | 
					    a->time_restart(e, &tvnext);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -153,7 +157,8 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OS_IS_WIN32
 | 
					#ifdef OS_IS_WIN32
 | 
				
			||||||
    pa_defer_event *defer;
 | 
					    pa_time_event *timer;
 | 
				
			||||||
 | 
					    struct timeval tv;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_limit_caps();
 | 
					    pa_limit_caps();
 | 
				
			||||||
| 
						 | 
					@ -386,8 +391,9 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
#ifdef OS_IS_WIN32
 | 
					#ifdef OS_IS_WIN32
 | 
				
			||||||
    defer = pa_mainloop_get_api(mainloop)->defer_new(pa_mainloop_get_api(mainloop), message_cb, NULL);
 | 
					    timer = pa_mainloop_get_api(mainloop)->time_new(
 | 
				
			||||||
    assert(defer);
 | 
					        pa_mainloop_get_api(mainloop), pa_gettimeofday(&tv), message_cb, NULL);
 | 
				
			||||||
 | 
					    assert(timer);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (conf->daemonize)
 | 
					    if (conf->daemonize)
 | 
				
			||||||
| 
						 | 
					@ -446,7 +452,7 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OS_IS_WIN32
 | 
					#ifdef OS_IS_WIN32
 | 
				
			||||||
    pa_mainloop_get_api(mainloop)->defer_free(defer);
 | 
					    pa_mainloop_get_api(mainloop)->time_free(timer);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_core_free(c);
 | 
					    pa_core_free(c);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,7 +59,7 @@ struct pa_signal_event {
 | 
				
			||||||
static pa_mainloop_api *api = NULL;
 | 
					static pa_mainloop_api *api = NULL;
 | 
				
			||||||
static int signal_pipe[2] = { -1, -1 };
 | 
					static int signal_pipe[2] = { -1, -1 };
 | 
				
			||||||
static pa_io_event* io_event = NULL;
 | 
					static pa_io_event* io_event = NULL;
 | 
				
			||||||
static pa_defer_event *defer_event = NULL;
 | 
					static pa_time_event *time_event = NULL;
 | 
				
			||||||
static pa_signal_event *signals = NULL;
 | 
					static pa_signal_event *signals = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OS_IS_WIN32
 | 
					#ifdef OS_IS_WIN32
 | 
				
			||||||
| 
						 | 
					@ -92,10 +92,11 @@ static void dispatch(pa_mainloop_api*a, int sig) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OS_IS_WIN32
 | 
					#ifdef OS_IS_WIN32
 | 
				
			||||||
static void defer(pa_mainloop_api*a, PA_GCC_UNUSED pa_defer_event*e, PA_GCC_UNUSED void *userdata) {
 | 
					static void timer(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, PA_GCC_UNUSED void *userdata) {
 | 
				
			||||||
    ssize_t r;
 | 
					    ssize_t r;
 | 
				
			||||||
    int sig;
 | 
					    int sig;
 | 
				
			||||||
    unsigned int sigs;
 | 
					    unsigned int sigs;
 | 
				
			||||||
 | 
					    struct timeval tvnext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EnterCriticalSection(&crit);
 | 
					    EnterCriticalSection(&crit);
 | 
				
			||||||
    sigs = waiting_signals;
 | 
					    sigs = waiting_signals;
 | 
				
			||||||
| 
						 | 
					@ -117,6 +118,9 @@ static void defer(pa_mainloop_api*a, PA_GCC_UNUSED pa_defer_event*e, PA_GCC_UNUS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        sigs--;
 | 
					        sigs--;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_timeval_add(pa_gettimeofday(&tvnext), 100000);
 | 
				
			||||||
 | 
					    a->time_restart(e, &tvnext);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -143,7 +147,11 @@ static void callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int pa_signal_init(pa_mainloop_api *a) {
 | 
					int pa_signal_init(pa_mainloop_api *a) {
 | 
				
			||||||
    assert(!api && a && signal_pipe[0] == -1 && signal_pipe[1] == -1 && !io_event && !defer_event);
 | 
					#ifdef OS_IS_WIN32
 | 
				
			||||||
 | 
					    struct timeval tv;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert(!api && a && signal_pipe[0] == -1 && signal_pipe[1] == -1 && !io_event && !time_event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OS_IS_WIN32
 | 
					#ifdef OS_IS_WIN32
 | 
				
			||||||
    if (_pipe(signal_pipe, 200, _O_BINARY) < 0) {
 | 
					    if (_pipe(signal_pipe, 200, _O_BINARY) < 0) {
 | 
				
			||||||
| 
						 | 
					@ -165,8 +173,8 @@ int pa_signal_init(pa_mainloop_api *a) {
 | 
				
			||||||
    io_event = api->io_new(api, signal_pipe[0], PA_IO_EVENT_INPUT, callback, NULL);
 | 
					    io_event = api->io_new(api, signal_pipe[0], PA_IO_EVENT_INPUT, callback, NULL);
 | 
				
			||||||
    assert(io_event);
 | 
					    assert(io_event);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    defer_event = api->defer_new(api, defer, NULL);
 | 
					    time_event = api->time_new(api, pa_gettimeofday(&tv), timer, NULL);
 | 
				
			||||||
    assert(defer_event);
 | 
					    assert(time_event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    InitializeCriticalSection(&crit);
 | 
					    InitializeCriticalSection(&crit);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -175,7 +183,7 @@ int pa_signal_init(pa_mainloop_api *a) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pa_signal_done(void) {
 | 
					void pa_signal_done(void) {
 | 
				
			||||||
    assert(api && signal_pipe[0] >= 0 && signal_pipe[1] >= 0 && (io_event || defer_event));
 | 
					    assert(api && signal_pipe[0] >= 0 && signal_pipe[1] >= 0 && (io_event || time_event));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (signals)
 | 
					    while (signals)
 | 
				
			||||||
        pa_signal_free(signals);
 | 
					        pa_signal_free(signals);
 | 
				
			||||||
| 
						 | 
					@ -184,8 +192,8 @@ void pa_signal_done(void) {
 | 
				
			||||||
    api->io_free(io_event);
 | 
					    api->io_free(io_event);
 | 
				
			||||||
    io_event = NULL;
 | 
					    io_event = NULL;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    api->defer_free(defer_event);
 | 
					    api->time_free(time_event);
 | 
				
			||||||
    defer_event = NULL;
 | 
					    time_event = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DeleteCriticalSection(&crit);
 | 
					    DeleteCriticalSection(&crit);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue