mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
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>
This commit is contained in:
parent
3d02559002
commit
950d5eedf9
1 changed files with 30 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue