#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;
+ struct timeval tvnext;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
DispatchMessage(&msg);
}
}
+
+ pa_timeval_add(pa_gettimeofday(&tvnext), 100000);
+ a->time_restart(e, &tvnext);
}
#endif
#endif
#ifdef OS_IS_WIN32
- pa_defer_event *defer;
+ pa_time_event *timer;
+ struct timeval tv;
#endif
pa_limit_caps();
#endif
#ifdef OS_IS_WIN32
- defer = pa_mainloop_get_api(mainloop)->defer_new(pa_mainloop_get_api(mainloop), message_cb, NULL);
- assert(defer);
+ timer = pa_mainloop_get_api(mainloop)->time_new(
+ pa_mainloop_get_api(mainloop), pa_gettimeofday(&tv), message_cb, NULL);
+ assert(timer);
#endif
if (conf->daemonize)
}
#ifdef OS_IS_WIN32
- pa_mainloop_get_api(mainloop)->defer_free(defer);
+ pa_mainloop_get_api(mainloop)->time_free(timer);
#endif
pa_core_free(c);
static pa_mainloop_api *api = NULL;
static int signal_pipe[2] = { -1, -1 };
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;
#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;
int sig;
unsigned int sigs;
+ struct timeval tvnext;
EnterCriticalSection(&crit);
sigs = waiting_signals;
sigs--;
}
+
+ pa_timeval_add(pa_gettimeofday(&tvnext), 100000);
+ a->time_restart(e, &tvnext);
}
#endif
}
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
if (_pipe(signal_pipe, 200, _O_BINARY) < 0) {
io_event = api->io_new(api, signal_pipe[0], PA_IO_EVENT_INPUT, callback, NULL);
assert(io_event);
#else
- defer_event = api->defer_new(api, defer, NULL);
- assert(defer_event);
+ time_event = api->time_new(api, pa_gettimeofday(&tv), timer, NULL);
+ assert(time_event);
InitializeCriticalSection(&crit);
#endif
}
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)
pa_signal_free(signals);
api->io_free(io_event);
io_event = NULL;
#else
- api->defer_free(defer_event);
- defer_event = NULL;
+ api->time_free(time_event);
+ time_event = NULL;
DeleteCriticalSection(&crit);
#endif