diff options
author | Lucas Stach <l.stach@pengutronix.de> | 2019-03-08 19:52:25 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2019-05-01 17:49:34 +0100 |
commit | 85c9b7670839801c766a9d1432a5bbc40abcb718 (patch) | |
tree | 2cb9c80edbf3918ed47811198a70a4a7fad2afe3 | |
parent | 53214e47309d116b1f6b4558bf0965d1d5e2849b (diff) | |
download | gstreamer-plugins-base-85c9b7670839801c766a9d1432a5bbc40abcb718.tar.gz |
gl/wayland: fix glib mainloop integration
Implement the prepare and check functions according to the
documentation by returning TRUE when events should be dispatched
via the dispatch function.
As wl_display_read_events never blocks we can call it unconditionally
without looking at the poll status.
This simplifies the implementation and gets rid of a race where the
mainloop could get blocked due to nobody actually reading the events
from the wayland connection.
-rw-r--r-- | gst-libs/gst/gl/wayland/wayland_event_source.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/gst-libs/gst/gl/wayland/wayland_event_source.c b/gst-libs/gst/gl/wayland/wayland_event_source.c index 12a066805..3f9d482ff 100644 --- a/gst-libs/gst/gl/wayland/wayland_event_source.c +++ b/gst-libs/gst/gl/wayland/wayland_event_source.c @@ -128,19 +128,13 @@ wayland_event_source_prepare (GSource * base, gint * timeout) wl_display_cancel_read (source->display); if (source->queue) { - while (wl_display_prepare_read_queue (source->display, source->queue) != 0) { - if (wl_display_dispatch_queue_pending (source->display, - source->queue) < 0) { - g_critical ("Failed to dispatch pending events\n"); - } - } + if (wl_display_prepare_read_queue (source->display, source->queue) != 0) + return TRUE; } else { - while (wl_display_prepare_read (source->display) != 0) { - if (wl_display_dispatch_pending (source->display) < 0) { - g_critical ("Failed to dispatch pending events\n"); - } - } + if (wl_display_prepare_read (source->display) != 0) + return TRUE; } + source->reading = TRUE; /* FIXME: this may return EAGAIN if the fd is full */ @@ -154,18 +148,13 @@ static gboolean wayland_event_source_check (GSource * base) { WaylandEventSource *source = (WaylandEventSource *) base; - gboolean retval; - - retval = source->pfd.revents; - if (source->pfd.revents & G_IO_IN) { - wl_display_read_events (source->display); - } else { - wl_display_cancel_read (source->display); - } source->reading = FALSE; - return retval; + if (wl_display_read_events (source->display) == 0) + return TRUE; + + return FALSE; } static gboolean |