]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: user-instance: delegate decision of poll timeout into application
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 10 Feb 2020 12:20:41 +0000 (21:20 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Tue, 11 Feb 2020 12:01:11 +0000 (21:01 +0900)
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 <o-takashi@sakamocchi.jp>
src/timer/user-instance.c

index d3b0c4869014456b6f471eef7c15d4e21913eb09..365956c9849f84631db8cb2619c4c05e7372432b 100644 (file)
@@ -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,