gl: Also don't leak floating references to elements set via properties

Fixup for 58ac815eae. Floating references
are such a mess.
This commit is contained in:
Sebastian Dröge 2018-07-25 15:03:59 +03:00
parent 58ac815eae
commit c2a7c93840
4 changed files with 19 additions and 23 deletions

View file

@ -173,7 +173,7 @@ _connect_filter_element (GstGLFilterBin * self)
} }
/* /*
* @filter: (transfer full): * @filter: (transfer floating):
*/ */
static gboolean static gboolean
gst_gl_filter_bin_set_filter (GstGLFilterBin * self, GstElement * filter) gst_gl_filter_bin_set_filter (GstGLFilterBin * self, GstElement * filter)
@ -189,10 +189,10 @@ gst_gl_filter_bin_set_filter (GstGLFilterBin * self, GstElement * filter)
} }
self->filter = filter; self->filter = filter;
if (filter && g_object_is_floating (filter)) gst_object_ref_sink (filter);
gst_object_ref_sink (filter);
if (filter && !_connect_filter_element (self)) { if (filter && !_connect_filter_element (self)) {
gst_object_unref (self->filter);
self->filter = NULL; self->filter = NULL;
return FALSE; return FALSE;
} }
@ -204,8 +204,7 @@ void
gst_gl_filter_bin_finish_init_with_element (GstGLFilterBin * self, gst_gl_filter_bin_finish_init_with_element (GstGLFilterBin * self,
GstElement * element) GstElement * element)
{ {
if (!gst_gl_filter_bin_set_filter (self, element)) gst_gl_filter_bin_set_filter (self, element);
gst_object_unref (element);
} }
void void
@ -245,7 +244,7 @@ gst_gl_filter_bin_set_property (GObject * object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_FILTER: case PROP_FILTER:
gst_gl_filter_bin_set_filter (self, g_value_dup_object (value)); gst_gl_filter_bin_set_filter (self, g_value_get_object (value));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

@ -399,7 +399,7 @@ _connect_mixer_element (GstGLMixerBin * self)
} }
/* /*
* @mixer: (transfer full): * @mixer: (transfer floating):
*/ */
static gboolean static gboolean
gst_gl_mixer_bin_set_mixer (GstGLMixerBin * self, GstElement * mixer) gst_gl_mixer_bin_set_mixer (GstGLMixerBin * self, GstElement * mixer)
@ -415,10 +415,10 @@ gst_gl_mixer_bin_set_mixer (GstGLMixerBin * self, GstElement * mixer)
} }
self->mixer = mixer; self->mixer = mixer;
if (mixer && g_object_is_floating (mixer)) gst_object_ref_sink (mixer);
gst_object_ref_sink (mixer);
if (mixer && !_connect_mixer_element (self)) { if (mixer && !_connect_mixer_element (self)) {
gst_object_unref (self->mixer);
self->mixer = NULL; self->mixer = NULL;
return FALSE; return FALSE;
} }
@ -430,8 +430,7 @@ void
gst_gl_mixer_bin_finish_init_with_element (GstGLMixerBin * self, gst_gl_mixer_bin_finish_init_with_element (GstGLMixerBin * self,
GstElement * element) GstElement * element)
{ {
if (!gst_gl_mixer_bin_set_mixer (self, element)) gst_gl_mixer_bin_set_mixer (self, element);
gst_object_unref (element);
} }
void void
@ -473,7 +472,7 @@ gst_gl_mixer_bin_set_property (GObject * object,
switch (prop_id) { switch (prop_id) {
case PROP_MIXER: case PROP_MIXER:
{ {
GstElement *mixer = g_value_dup_object (value); GstElement *mixer = g_value_get_object (value);
/* FIXME: deal with replacing a mixer */ /* FIXME: deal with replacing a mixer */
g_return_if_fail (!self->mixer || (self->mixer == mixer)); g_return_if_fail (!self->mixer || (self->mixer == mixer));
gst_gl_mixer_bin_set_mixer (self, mixer); gst_gl_mixer_bin_set_mixer (self, mixer);

View file

@ -307,10 +307,10 @@ gst_gl_sink_bin_set_sink (GstGLSinkBin * self, GstElement * sink)
} }
self->sink = sink; self->sink = sink;
if (sink && g_object_is_floating (sink)) gst_object_ref_sink (sink);
gst_object_ref_sink (sink);
if (sink && !_connect_sink_element (self)) { if (sink && !_connect_sink_element (self)) {
gst_object_unref (self->sink);
self->sink = NULL; self->sink = NULL;
return FALSE; return FALSE;
} }
@ -322,8 +322,7 @@ void
gst_gl_sink_bin_finish_init_with_element (GstGLSinkBin * self, gst_gl_sink_bin_finish_init_with_element (GstGLSinkBin * self,
GstElement * element) GstElement * element)
{ {
if (!gst_gl_sink_bin_set_sink (self, element)) gst_gl_sink_bin_set_sink (self, element);
gst_object_unref (element);
} }
void void
@ -347,7 +346,7 @@ gst_gl_sink_bin_set_property (GObject * object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_SINK: case PROP_SINK:
gst_gl_sink_bin_set_sink (self, g_value_dup_object (value)); gst_gl_sink_bin_set_sink (self, g_value_get_object (value));
break; break;
case PROP_CONTRAST: case PROP_CONTRAST:
case PROP_BRIGHTNESS: case PROP_BRIGHTNESS:

View file

@ -165,7 +165,7 @@ _connect_src_element (GstGLSrcBin * self)
} }
/* /*
* @src: (transfer full): * @src: (transfer floating):
*/ */
static gboolean static gboolean
gst_gl_src_bin_set_src (GstGLSrcBin * self, GstElement * src) gst_gl_src_bin_set_src (GstGLSrcBin * self, GstElement * src)
@ -181,10 +181,10 @@ gst_gl_src_bin_set_src (GstGLSrcBin * self, GstElement * src)
} }
self->src = src; self->src = src;
if (src && g_object_is_floating (src)) gst_object_ref_sink (src);
gst_object_ref_sink (src);
if (src && !_connect_src_element (self)) { if (src && !_connect_src_element (self)) {
gst_object_unref (self->src);
self->src = NULL; self->src = NULL;
return FALSE; return FALSE;
} }
@ -196,8 +196,7 @@ void
gst_gl_src_bin_finish_init_with_element (GstGLSrcBin * self, gst_gl_src_bin_finish_init_with_element (GstGLSrcBin * self,
GstElement * element) GstElement * element)
{ {
if (!gst_gl_src_bin_set_src (self, element)) gst_gl_src_bin_set_src (self, element);
gst_object_unref (self->src);
} }
void void
@ -221,7 +220,7 @@ gst_gl_src_bin_set_property (GObject * object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_SRC: case PROP_SRC:
gst_gl_src_bin_set_src (self, g_value_dup_object (value)); gst_gl_src_bin_set_src (self, g_value_get_object (value));
break; break;
default: default:
if (self->src) if (self->src)