From: Takashi Sakamoto Date: Mon, 10 Feb 2020 12:20:17 +0000 (+0900) Subject: ctl: card: delegate decision of poll timeout into application X-Git-Tag: v0.1.0~316 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=d33414977a5c8828c96c7a3d5125d5993c637383;p=alsa-gobject.git ctl: card: 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/ctl/card.c b/src/ctl/card.c index 953920f..d4d7d6c 100644 --- a/src/ctl/card.c +++ b/src/ctl/card.c @@ -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,