mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 15:48:23 +00:00
GstGLSinkBin: fixed sink property leak
No need to keep an extra reference to sink since an indirect one is added by gst_bin_add() https://bugzilla.gnome.org/show_bug.cgi?id=778452
This commit is contained in:
parent
0102caf06d
commit
ef739e726f
1 changed files with 24 additions and 26 deletions
|
@ -267,31 +267,38 @@ gst_gl_sink_bin_init (GstGLSinkBin * self)
|
|||
static gboolean
|
||||
_connect_sink_element (GstGLSinkBin * self)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
|
||||
gst_object_set_name (GST_OBJECT (self->sink), "sink");
|
||||
res &= gst_bin_add (GST_BIN (self), self->sink);
|
||||
|
||||
res &= gst_element_link_pads (self->balance, "src", self->sink, "sink");
|
||||
if (gst_bin_add (GST_BIN (self), self->sink) &&
|
||||
gst_element_link_pads (self->balance, "src", self->sink, "sink"))
|
||||
return TRUE;
|
||||
|
||||
if (!res)
|
||||
GST_ERROR_OBJECT (self, "Failed to link sink element into the pipeline");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return res;
|
||||
static void
|
||||
gst_gl_sink_bin_set_sink (GstGLSinkBin * self, GstElement * sink)
|
||||
{
|
||||
g_return_if_fail (GST_IS_ELEMENT (sink));
|
||||
|
||||
if (self->sink) {
|
||||
gst_bin_remove (GST_BIN (self), self->sink);
|
||||
self->sink = NULL;
|
||||
}
|
||||
|
||||
/* We keep an indirect reference when the element is added */
|
||||
self->sink = sink;
|
||||
|
||||
if (sink && !_connect_sink_element (self))
|
||||
self->sink = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_sink_bin_finish_init_with_element (GstGLSinkBin * self,
|
||||
GstElement * element)
|
||||
{
|
||||
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||
|
||||
self->sink = element;
|
||||
|
||||
if (!_connect_sink_element (self)) {
|
||||
gst_object_unref (self->sink);
|
||||
self->sink = NULL;
|
||||
}
|
||||
gst_gl_sink_bin_set_sink (self, element);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -304,7 +311,7 @@ gst_gl_sink_bin_finish_init (GstGLSinkBin * self)
|
|||
element = klass->create_element ();
|
||||
|
||||
if (element)
|
||||
gst_gl_sink_bin_finish_init_with_element (self, element);
|
||||
gst_gl_sink_bin_set_sink (self, element);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -315,17 +322,8 @@ gst_gl_sink_bin_set_property (GObject * object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_SINK:
|
||||
{
|
||||
GstElement *sink = g_value_get_object (value);
|
||||
if (self->sink)
|
||||
gst_bin_remove (GST_BIN (self), self->sink);
|
||||
self->sink = sink;
|
||||
if (sink) {
|
||||
gst_object_ref_sink (sink);
|
||||
_connect_sink_element (self);
|
||||
}
|
||||
gst_gl_sink_bin_set_sink (self, g_value_get_object (value));
|
||||
break;
|
||||
}
|
||||
case PROP_CONTRAST:
|
||||
case PROP_BRIGHTNESS:
|
||||
case PROP_HUE:
|
||||
|
|
Loading…
Reference in a new issue