diff options
author | Philippe Normand <philn@igalia.com> | 2020-08-22 14:38:38 +0100 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-08-24 20:59:50 +0000 |
commit | 2caa3e023098830cdc21c3f1d4479eea338cb783 (patch) | |
tree | a3455a783839342b08a9e176ddbb3a00a96800f5 /ext | |
parent | 25c87a1315457c6be905768055a5072ed29474ee (diff) | |
download | gstreamer-plugins-bad-2caa3e023098830cdc21c3f1d4479eea338cb783.tar.gz |
wpe: skip glbasesrc decide_allocation when non-GL caps are negotiated
Checking for GL caps features in gl_start() was done too late in case the parent
class fails to setup a working GL context. The element now determines if GL
support should be enabled during the decide-allocation query handling.
Additionally, when no GL context was found, we need to handle the element
cleanup because in that situation glbasesrc won't call gl_stop.
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1376
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1532>
Diffstat (limited to 'ext')
-rw-r--r-- | ext/wpe/gstwpesrc.cpp | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/ext/wpe/gstwpesrc.cpp b/ext/wpe/gstwpesrc.cpp index f303a3da8..9e81ab122 100644 --- a/ext/wpe/gstwpesrc.cpp +++ b/ext/wpe/gstwpesrc.cpp @@ -234,23 +234,18 @@ gst_wpe_src_fill_memory (GstGLBaseSrc * bsrc, GstGLMemory * memory) } static gboolean -gst_wpe_src_gl_start (GstGLBaseSrc * base_src) +gst_wpe_src_start (GstWpeSrc * src) { - GstWpeSrc *src = GST_WPE_SRC (base_src); - GstCapsFeatures *caps_features; GstGLContext *context = NULL; GstGLDisplay *display = NULL; + GstGLBaseSrc *base_src = GST_GL_BASE_SRC (src); GST_INFO_OBJECT (src, "Starting up"); GST_OBJECT_LOCK (src); - caps_features = gst_caps_get_features (base_src->out_caps, 0); - if (caps_features != NULL && gst_caps_features_contains (caps_features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) { - src->gl_enabled = TRUE; + if (src->gl_enabled) { context = base_src->context; display = base_src->display; - } else { - src->gl_enabled = FALSE; } GST_DEBUG_OBJECT (src, "Will fill GLMemories: %d\n", src->gl_enabled); @@ -278,16 +273,73 @@ gst_wpe_src_gl_start (GstGLBaseSrc * base_src) return TRUE; } -static void -gst_wpe_src_gl_stop (GstGLBaseSrc * base_src) +static gboolean +gst_wpe_src_decide_allocation (GstBaseSrc * base_src, GstQuery * query) { + GstGLBaseSrc *gl_src = GST_GL_BASE_SRC (base_src); GstWpeSrc *src = GST_WPE_SRC (base_src); + GstCapsFeatures *caps_features; + + GST_OBJECT_LOCK (src); + caps_features = gst_caps_get_features (gl_src->out_caps, 0); + if (caps_features != NULL && gst_caps_features_contains (caps_features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) { + src->gl_enabled = TRUE; + } else { + src->gl_enabled = FALSE; + } + + if (src->gl_enabled) { + GST_OBJECT_UNLOCK (src); + return GST_CALL_PARENT_WITH_DEFAULT(GST_BASE_SRC_CLASS, decide_allocation, (base_src, query), FALSE); + } + GST_OBJECT_UNLOCK (src); + return gst_wpe_src_start (src); +} + +static gboolean +gst_wpe_src_gl_start (GstGLBaseSrc * base_src) +{ + GstWpeSrc *src = GST_WPE_SRC (base_src); + return gst_wpe_src_start (src); +} + +static void +gst_wpe_src_stop_unlocked (GstWpeSrc * src) +{ if (src->view) { delete src->view; src->view = NULL; } } +static void +gst_wpe_src_gl_stop (GstGLBaseSrc * base_src) +{ + GstWpeSrc *src = GST_WPE_SRC (base_src); + + GST_OBJECT_LOCK (src); + gst_wpe_src_stop_unlocked (src); + GST_OBJECT_UNLOCK (src); +} + +static gboolean +gst_wpe_src_stop (GstBaseSrc * base_src) +{ + GstWpeSrc *src = GST_WPE_SRC (base_src); + + GST_OBJECT_LOCK (src); + + if (src->gl_enabled) { + GST_OBJECT_UNLOCK (src); + // Let glbasesrc call our gl_stop() within its GL context. + return GST_CALL_PARENT_WITH_DEFAULT(GST_BASE_SRC_CLASS, stop, (base_src), FALSE); + } + + gst_wpe_src_stop_unlocked (src); + GST_OBJECT_UNLOCK (src); + return TRUE; +} + static GstCaps * gst_wpe_src_fixate (GstBaseSrc * base_src, GstCaps * caps) { @@ -619,6 +671,8 @@ gst_wpe_src_class_init (GstWpeSrcClass * klass) base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_wpe_src_fixate); base_src_class->create = GST_DEBUG_FUNCPTR (gst_wpe_src_create); + base_src_class->decide_allocation = GST_DEBUG_FUNCPTR (gst_wpe_src_decide_allocation); + base_src_class->stop = GST_DEBUG_FUNCPTR (gst_wpe_src_stop); gl_base_src_class->supported_gl_api = static_cast < GstGLAPI > |