From 6fc7455881b5d9bf2e432e1a532377601be8946d Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 25 Aug 2020 01:57:55 +1000 Subject: [PATCH] wpesrc: Don't crash if WPE doesn't generate a buffer. On creating a 2nd wpesrc in a new pipeline in an app that already has a runnig wpesrc, WPE sometimes doesn't return a buffer on request, leading to a crash. This commit fixes the crash, but not the underlying failure - a 2nd wpesrc can still error out instead. Partially fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1386 Part-of: --- ext/wpe/gstwpesrc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ext/wpe/gstwpesrc.cpp b/ext/wpe/gstwpesrc.cpp index 9e81ab1..970c742 100644 --- a/ext/wpe/gstwpesrc.cpp +++ b/ext/wpe/gstwpesrc.cpp @@ -169,11 +169,13 @@ gst_wpe_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, GstBuffer * } locked_buffer = src->view->buffer (); - - if (locked_buffer != NULL) { - *buf = gst_buffer_copy_deep (locked_buffer); - ret = GST_FLOW_OK; + if (locked_buffer == NULL) { + GST_OBJECT_UNLOCK (src); + GST_ELEMENT_ERROR (src, RESOURCE, FAILED, + ("WPE View did not render a buffer"), (NULL)); + return ret; } + *buf = gst_buffer_copy_deep (locked_buffer); g_object_get(gl_src, "timestamp-offset", &ts_offset, NULL); @@ -195,6 +197,7 @@ gst_wpe_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, GstBuffer * gl_src->running_time = next_time; + ret = GST_FLOW_OK; GST_OBJECT_UNLOCK (src); return ret; } -- 2.7.4