waylandsink: Fix double render check

Our code does not support rendering twice the same wl_buffer in a row, so it
tries to skip that case, but for this it relied on the GstBuffer pointer,
while the cache actually works at the GstMemory level now. To avoid this
compare the GstWlBuffer instead.

This fixes crash when use in zero-copy with videorate element.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2526>
This commit is contained in:
Nicolas Dufresne 2021-09-16 17:12:58 -04:00 committed by GStreamer Marge Bot
parent f51371d7b9
commit afa1c19b37
2 changed files with 14 additions and 5 deletions

View file

@ -829,7 +829,7 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
if (G_UNLIKELY (!wbuf))
goto no_wl_buffer_shm;
gst_buffer_add_wl_buffer (to_render, wbuf, sink->display);
wlbuffer = gst_buffer_add_wl_buffer (to_render, wbuf, sink->display);
}
if (!gst_video_frame_map (&dst, &sink->video_info, to_render,
@ -853,12 +853,13 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
if (!wbuf)
goto no_wl_buffer;
gst_buffer_add_wl_buffer (buffer, wbuf, sink->display);
wlbuffer = gst_buffer_add_wl_buffer (buffer, wbuf, sink->display);
to_render = buffer;
render:
/* drop double rendering */
if (G_UNLIKELY (to_render == sink->last_buffer)) {
if (G_UNLIKELY (wlbuffer ==
gst_buffer_get_wl_buffer (sink->display, sink->last_buffer))) {
GST_LOG_OBJECT (sink, "Buffer already being rendered");
goto done;
}

View file

@ -185,10 +185,18 @@ gst_buffer_add_wl_buffer (GstBuffer * gstbuffer, struct wl_buffer *wlbuffer,
GstWlBuffer *
gst_buffer_get_wl_buffer (GstWlDisplay * display, GstBuffer * gstbuffer)
{
GstMemory *mem0 = gst_buffer_peek_memory (gstbuffer, 0);
GstWlBuffer *wlbuf = gst_wl_display_lookup_buffer (display, mem0);
GstMemory *mem0;
GstWlBuffer *wlbuf;
if (!gstbuffer)
return NULL;
mem0 = gst_buffer_peek_memory (gstbuffer, 0);
wlbuf = gst_wl_display_lookup_buffer (display, mem0);
if (wlbuf)
wlbuf->current_gstbuffer = gstbuffer;
return wlbuf;
}