From: Takashi Sakamoto Date: Mon, 10 Feb 2020 12:20:41 +0000 (+0900) Subject: timer: user-instance: delegate decision of poll timeout into application X-Git-Tag: v0.1.0~315 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=7afb66bdd6c90cf598503db0d2123d31ff89d292;p=alsa-gobject.git timer: user-instance: delegate decision of poll timeout into application As long as using the created Gsource with GMainContext, the call of poll(2) system call with infinite timeout surely returns when quit() method is called for the context. All of GMainContext implements GWakeup with eventfd and the call of quit() emits event via file descriptor of eventfd. This brings wakeup from blocking when poll(2) is called with inifinite timeout. This means that it's necessarily need to have explicit timeout internally. This commit removes implementation of GSourceFunc.prepare for the reason. Signed-off-by: Takashi Sakamoto --- diff --git a/src/timer/user-instance.c b/src/timer/user-instance.c index d3b0c48..365956c 100644 --- a/src/timer/user-instance.c +++ b/src/timer/user-instance.c @@ -316,14 +316,6 @@ static void handle_timestamp_events(TimerUserInstanceSource *src, int len) } } -static gboolean timer_user_instance_prepare_src(GSource *src, gint *timeout) -{ - *timeout = 500; - - // This source is not ready, let's poll(2). - return FALSE; -} - static gboolean timer_user_instance_check_src(GSource *gsrc) { TimerUserInstanceSource *src = (TimerUserInstanceSource *)gsrc; @@ -395,7 +387,6 @@ void alsatimer_user_instance_create_source(ALSATimerUserInstance *self, GSource **gsrc, GError **error) { static GSourceFuncs funcs = { - .prepare = timer_user_instance_prepare_src, .check = timer_user_instance_check_src, .dispatch = timer_user_instance_dispatch_src, .finalize = timer_user_instance_finalize_src,