mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
gl/wayland: use wayland's roundtrip_queue()
There's no need to roll our own anymore
This commit is contained in:
parent
0739fafd62
commit
f58914b93b
3 changed files with 4 additions and 77 deletions
|
@ -554,8 +554,8 @@ gst_gl_window_wayland_egl_open (GstGLWindow * window, GError ** error)
|
|||
wl_registry_add_listener (window_egl->display.registry, ®istry_listener,
|
||||
window_egl);
|
||||
|
||||
if (gst_gl_wl_display_roundtrip_queue (window_egl->display.display,
|
||||
display->display, window_egl->window.queue) < 0) {
|
||||
if (wl_display_roundtrip_queue (display->display,
|
||||
window_egl->window.queue) < 0) {
|
||||
g_set_error (error, GST_GL_WINDOW_ERROR,
|
||||
GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
|
||||
"Failed to perform a wayland roundtrip");
|
||||
|
@ -610,8 +610,8 @@ _roundtrip_async (GstGLWindow * window)
|
|||
|
||||
create_surfaces (window_egl);
|
||||
|
||||
if (gst_gl_wl_display_roundtrip_queue (window_egl->display.display,
|
||||
display->display, window_egl->window.queue) < 0)
|
||||
if (wl_display_roundtrip_queue (display->display,
|
||||
window_egl->window.queue) < 0)
|
||||
GST_WARNING_OBJECT (window, "failed a roundtrip");
|
||||
}
|
||||
|
||||
|
|
|
@ -54,75 +54,6 @@ init_debug (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sync_callback (void *data, struct wl_callback *callback, uint32_t serial)
|
||||
{
|
||||
gboolean *done = data;
|
||||
|
||||
GST_TRACE ("roundtrip done. callback:%p", callback);
|
||||
|
||||
*done = TRUE;
|
||||
wl_callback_destroy (callback);
|
||||
}
|
||||
|
||||
static const struct wl_callback_listener sync_listener = {
|
||||
sync_callback
|
||||
};
|
||||
|
||||
/* only thread safe iff called on the same thread @queue is being dispatched on.
|
||||
* Otherwise, two prepare_read{_queue}()'s can be indicated for the same
|
||||
* queue and dispatch{_queue}() may be called for different threads which
|
||||
* will cause deadlocks as no guarantees for thread-safety are given when
|
||||
* pumping the same queue from multiple threads.
|
||||
* As a concrete example, if the wayland event source (below) for a @queue is
|
||||
* running on a certain thread, then this function must only be called in that
|
||||
* thread (with that @queue). */
|
||||
/* @sync_display is the wl_display that is used to create the sync object and
|
||||
* may be a proxy wrapper.
|
||||
* @dispatch_display must not be a proxy wrapper.
|
||||
* @queue can be NULL. */
|
||||
gint
|
||||
gst_gl_wl_display_roundtrip_queue (struct wl_display *sync_display,
|
||||
struct wl_display *dispatch_display, struct wl_event_queue *queue)
|
||||
{
|
||||
struct wl_callback *callback;
|
||||
gboolean done = FALSE;
|
||||
gint ret = 0;
|
||||
|
||||
init_debug ();
|
||||
|
||||
GST_TRACE ("roundtrip start for dpy %p and queue %p", dispatch_display,
|
||||
queue);
|
||||
|
||||
if (!(callback = wl_display_sync (sync_display))) {
|
||||
GST_WARNING ("creating sync callback failed");
|
||||
return -1;
|
||||
}
|
||||
GST_TRACE ("create roundtrip callback %p", callback);
|
||||
wl_callback_add_listener (callback, &sync_listener, &done);
|
||||
if (queue) {
|
||||
while (!done && ret >= 0) {
|
||||
ret = wl_display_dispatch_queue (dispatch_display, queue);
|
||||
GST_TRACE ("dispatch ret: %i, errno: (%i, 0x%x) \'%s\'", ret, errno,
|
||||
errno, g_strerror (errno));
|
||||
}
|
||||
} else {
|
||||
while (!done && ret >= 0) {
|
||||
ret = wl_display_dispatch (dispatch_display);
|
||||
GST_TRACE ("dispatch ret: %i, errno: (%i, 0x%x) \'%s\'", ret, errno,
|
||||
errno, g_strerror (errno));
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == -1 && !done)
|
||||
wl_callback_destroy (callback);
|
||||
GST_DEBUG ("roundtrip done for dpy %p and queue %p. ret %i, "
|
||||
"errno: (%i, 0x%x) \'%s\'", dispatch_display, queue, ret, errno, errno,
|
||||
g_strerror (errno));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct _WaylandEventSource
|
||||
{
|
||||
GSource source;
|
||||
|
|
|
@ -36,8 +36,4 @@
|
|||
GSource * wayland_event_source_new (struct wl_display *display,
|
||||
struct wl_event_queue *queue);
|
||||
|
||||
G_GNUC_INTERNAL gint gst_gl_wl_display_roundtrip_queue (struct wl_display *sync_display,
|
||||
struct wl_display *dispatch_display,
|
||||
struct wl_event_queue *queue);
|
||||
|
||||
#endif /* __WAYLAND_EVENT_SOURCE_H__ */
|
||||
|
|
Loading…
Reference in a new issue