summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>2021-05-06 19:17:29 +0200
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-05-07 16:01:49 +0000
commit950d5eedf940776e7dfe27a0e7fd34ce4fa163a8 (patch)
tree7879b2047c99232a2a68585e37e6af2137cb20ee /ext
parent3d0255900284a77b9bf686240e696631d24a8e77 (diff)
downloadgstreamer-plugins-bad-950d5eedf940776e7dfe27a0e7fd34ce4fa163a8.tar.gz
wpe: Properly lock property fields
Use the object lock for the following fields: - `bytes`: Written by the `load-bytes` signal unless running; consumed on start. - `draw_background`: Read and written by the `draw-background` property. - `location`: Read and written by the `location` property and the URI handler. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2222>
Diffstat (limited to 'ext')
-rw-r--r--ext/wpe/gstwpesrc.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/ext/wpe/gstwpesrc.cpp b/ext/wpe/gstwpesrc.cpp
index fa1a1ca4a..2660ae853 100644
--- a/ext/wpe/gstwpesrc.cpp
+++ b/ext/wpe/gstwpesrc.cpp
@@ -264,6 +264,7 @@ gst_wpe_src_start (GstWpeSrc * src)
GstGLDisplay *display = NULL;
GstGLBaseSrc *base_src = GST_GL_BASE_SRC (src);
gboolean created_view = FALSE;
+ GBytes *bytes;
GST_INFO_OBJECT (src, "Starting up");
WPE_LOCK (src);
@@ -292,10 +293,14 @@ gst_wpe_src_start (GstWpeSrc * src)
return FALSE;
}
- if (src->bytes != NULL) {
- src->view->loadData (src->bytes);
- g_bytes_unref (src->bytes);
- src->bytes = NULL;
+ GST_OBJECT_LOCK (src);
+ bytes = src->bytes;
+ src->bytes = NULL;
+ GST_OBJECT_UNLOCK (src);
+
+ if (bytes != NULL) {
+ src->view->loadData (bytes);
+ g_bytes_unref (bytes);
}
if (created_view) {
@@ -431,9 +436,11 @@ gst_wpe_src_load_bytes (GstWpeSrc * src, GBytes * bytes)
if (src->view && GST_STATE (GST_ELEMENT_CAST (src)) > GST_STATE_NULL) {
src->view->loadData (bytes);
} else {
+ GST_OBJECT_LOCK (src);
if (src->bytes)
g_bytes_unref (src->bytes);
src->bytes = g_bytes_ref (bytes);
+ GST_OBJECT_UNLOCK (src);
}
}
@@ -441,10 +448,13 @@ static gboolean
gst_wpe_src_set_location (GstWpeSrc * src, const gchar * location,
GError ** error)
{
+ GST_OBJECT_LOCK (src);
g_free (src->location);
src->location = g_strdup (location);
+ GST_OBJECT_UNLOCK (src);
+
if (src->view)
- src->view->loadUri (src->location);
+ src->view->loadUri (location);
return TRUE;
}
@@ -452,9 +462,12 @@ gst_wpe_src_set_location (GstWpeSrc * src, const gchar * location,
static void
gst_wpe_src_set_draw_background (GstWpeSrc * src, gboolean draw_background)
{
+ GST_OBJECT_LOCK (src);
+ src->draw_background = draw_background;
+ GST_OBJECT_UNLOCK (src);
+
if (src->view)
src->view->setDrawBackground (draw_background);
- src->draw_background = draw_background;
}
static void
@@ -496,10 +509,14 @@ gst_wpe_src_get_property (GObject * object, guint prop_id, GValue * value,
switch (prop_id) {
case PROP_LOCATION:
+ GST_OBJECT_LOCK (src);
g_value_set_string (value, src->location);
+ GST_OBJECT_UNLOCK (src);
break;
case PROP_DRAW_BACKGROUND:
+ GST_OBJECT_LOCK (src);
g_value_set_boolean (value, src->draw_background);
+ GST_OBJECT_UNLOCK (src);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -671,7 +688,13 @@ static gchar *
gst_wpe_src_get_uri (GstURIHandler * handler)
{
GstWpeSrc *src = GST_WPE_SRC (handler);
- return g_strdup_printf ("wpe://%s", src->location);
+ gchar *uri;
+
+ GST_OBJECT_LOCK (src);
+ uri = g_strdup_printf ("wpe://%s", src->location);
+ GST_OBJECT_UNLOCK (src);
+
+ return uri;
}
static gboolean