mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
gtksink: Return reference to GtkWidget in the acquire function
This should ensure thread safety. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1088>
This commit is contained in:
parent
103ceb853a
commit
941c0e81dd
2 changed files with 21 additions and 11 deletions
|
@ -178,7 +178,7 @@ static GtkGstBaseWidget *
|
|||
gst_gtk_base_sink_get_widget (GstGtkBaseSink * gtk_sink)
|
||||
{
|
||||
if (gtk_sink->widget != NULL)
|
||||
return gtk_sink->widget;
|
||||
return g_object_ref (gtk_sink->widget);
|
||||
|
||||
/* Ensure GTK is initialized, this has no side effect if it was already
|
||||
* initialized. Also, we do that lazily, so the application can be first */
|
||||
|
@ -211,7 +211,7 @@ gst_gtk_base_sink_get_widget (GstGtkBaseSink * gtk_sink)
|
|||
gtk_gst_base_widget_set_element (GTK_GST_BASE_WIDGET (gtk_sink->widget),
|
||||
GST_ELEMENT (gtk_sink));
|
||||
|
||||
return gtk_sink->widget;
|
||||
return g_object_ref (gtk_sink->widget);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -221,7 +221,7 @@ gst_gtk_base_sink_acquire_widget (GstGtkBaseSink * gtk_sink)
|
|||
|
||||
GST_OBJECT_LOCK (gtk_sink);
|
||||
if (gtk_sink->widget != NULL)
|
||||
widget = gtk_sink->widget;
|
||||
widget = g_object_ref (gtk_sink->widget);
|
||||
GST_OBJECT_UNLOCK (gtk_sink);
|
||||
|
||||
if (!widget)
|
||||
|
@ -241,7 +241,7 @@ gst_gtk_base_sink_get_property (GObject * object, guint prop_id,
|
|||
switch (prop_id) {
|
||||
case PROP_WIDGET:
|
||||
{
|
||||
g_value_set_object (value, gst_gtk_base_sink_acquire_widget (gtk_sink));
|
||||
g_value_take_object (value, gst_gtk_base_sink_acquire_widget (gtk_sink));
|
||||
break;
|
||||
}
|
||||
case PROP_FORCE_ASPECT_RATIO:
|
||||
|
|
|
@ -136,11 +136,14 @@ gst_gtk_gl_sink_set_property (GObject * object, guint prop_id,
|
|||
{
|
||||
switch (prop_id) {
|
||||
case PROP_ROTATE_METHOD:
|
||||
gtk_gst_gl_widget_set_rotate_method (GTK_GST_GL_WIDGET
|
||||
(gst_gtk_base_sink_acquire_widget (GST_GTK_BASE_SINK (object))),
|
||||
{
|
||||
GtkWidget *widget =
|
||||
gst_gtk_base_sink_acquire_widget (GST_GTK_BASE_SINK (object));
|
||||
gtk_gst_gl_widget_set_rotate_method (GTK_GST_GL_WIDGET (widget),
|
||||
g_value_get_enum (value), FALSE);
|
||||
g_object_unref (widget);
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -154,11 +157,16 @@ gst_gtk_gl_sink_get_property (GObject * object, guint prop_id,
|
|||
{
|
||||
switch (prop_id) {
|
||||
case PROP_ROTATE_METHOD:
|
||||
g_value_set_enum (value,
|
||||
gtk_gst_gl_widget_get_rotate_method (GTK_GST_GL_WIDGET
|
||||
(gst_gtk_base_sink_acquire_widget (GST_GTK_BASE_SINK (object)))));
|
||||
break;
|
||||
{
|
||||
GtkWidget *widget =
|
||||
gst_gtk_base_sink_acquire_widget (GST_GTK_BASE_SINK (object));
|
||||
|
||||
g_value_set_enum (value,
|
||||
gtk_gst_gl_widget_get_rotate_method (GTK_GST_GL_WIDGET (widget)));
|
||||
g_object_unref (widget);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -454,6 +462,8 @@ gst_gtk_gl_sink_event (GstBaseSink * sink, GstEvent * event)
|
|||
(gst_gtk_base_sink_acquire_widget (GST_GTK_BASE_SINK (sink)));
|
||||
|
||||
gtk_gst_gl_widget_set_rotate_method (widget, orientation, TRUE);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue