]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
ctl: card: delegate decision of poll timeout into application
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 10 Feb 2020 12:20:17 +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/ctl/card.c

index 953920f99c8c130e2a13194eeb0da17fb6438113..d4d7d6c4d8ee8367fd684e165f5a90829087ebaa 100644 (file)
@@ -778,14 +778,6 @@ static void handle_elem_event(CtlCardSource *src, struct snd_ctl_event *ev)
                   elem_id, mask);
 }
 
-static gboolean ctl_card_prepare_src(GSource *src, gint *timeout)
-{
-    *timeout = 500;
-
-    // This source is not ready, let's poll(2).
-    return FALSE;
-}
-
 static gboolean ctl_card_check_src(GSource *gsrc)
 {
     CtlCardSource *src = (CtlCardSource *)gsrc;
@@ -868,7 +860,6 @@ void alsactl_card_create_source(ALSACtlCard *self, GSource **gsrc,
                                 GError **error)
 {
     static GSourceFuncs funcs = {
-            .prepare        = ctl_card_prepare_src,
             .check          = ctl_card_check_src,
             .dispatch       = ctl_card_dispatch_src,
             .finalize       = ctl_card_finalize_src,