From 2a9d562cc6a5a1ce3bc2ae6596109750a0f54fc6 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 20 Sep 2013 10:28:20 +0200 Subject: [PATCH 8/8] daemon: get rid of win32 message timer We don't need a timer to check for Windows messages anymore now that our fancy new poll() implementation does that for us. --- src/daemon/main.c | 34 ---------------------------------- src/pulsecore/poll-win32.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/src/daemon/main.c b/src/daemon/main.c index 5b4e005..0d24872 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -114,27 +114,6 @@ int deny_severity = LOG_WARNING; int __padsp_disabled__ = 7; #endif -#ifdef OS_IS_WIN32 - -static void message_cb(pa_mainloop_api*a, pa_time_event*e, const struct timeval *tv, void *userdata) { - MSG msg; - struct timeval tvnext; - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) - raise(SIGTERM); - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - pa_timeval_add(pa_gettimeofday(&tvnext), 100000); - a->time_restart(e, &tvnext); -} - -#endif - static void signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) { pa_log_info(_("Got signal %s."), pa_sig2str(sig)); @@ -410,10 +389,6 @@ int main(int argc, char *argv[]) { int daemon_pipe[2] = { -1, -1 }; int daemon_pipe2[2] = { -1, -1 }; #endif -#ifdef OS_IS_WIN32 - pa_time_event *win32_timer; - struct timeval win32_tv; -#endif int autospawn_fd = -1; bool autospawn_locked = false; #ifdef HAVE_DBUS @@ -1066,10 +1041,6 @@ int main(int argc, char *argv[]) { pa_signal_new(SIGHUP, signal_callback, c); #endif -#ifdef OS_IS_WIN32 - win32_timer = pa_mainloop_get_api(mainloop)->time_new(pa_mainloop_get_api(mainloop), pa_gettimeofday(&win32_tv), message_cb, NULL); -#endif - if (!conf->no_cpu_limit) pa_assert_se(pa_cpu_limit_init(pa_mainloop_get_api(mainloop)) == 0); @@ -1164,11 +1135,6 @@ finish: pa_autospawn_lock_done(false); } -#ifdef OS_IS_WIN32 - if (mainloop && win32_timer) - pa_mainloop_get_api(mainloop)->time_free(win32_timer); -#endif - if (c) { /* Ensure all the modules/samples are unloaded when the core is still ref'ed, * as unlink callback hooks in modules may need the core to be ref'ed */ diff --git a/src/pulsecore/poll-win32.c b/src/pulsecore/poll-win32.c index 169a1ec..c927e53 100644 --- a/src/pulsecore/poll-win32.c +++ b/src/pulsecore/poll-win32.c @@ -46,6 +46,7 @@ typedef unsigned long nfds_t; # include # include # include +# include # if 0 # include "msvc-nothrow.h" # endif @@ -568,8 +569,13 @@ restart: BOOL bRet; while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0) { - TranslateMessage (&msg); - DispatchMessage (&msg); + if (msg.message == WM_QUIT) + raise(SIGTERM); + else + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } } } else -- 1.8.3.1