diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2016-05-19 17:05:33 +0300 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2016-05-20 17:09:33 +0200 |
commit | fe7dd131f5a441fc3f73790bc8447cb454362dc9 (patch) | |
tree | 7633f9752372f112c34fea9af06be0cdadf66d84 /ext/gl | |
parent | 2572e3d25c1192faba7bc89d26d26192efdd0481 (diff) | |
download | gstreamer-plugins-bad-fe7dd131f5a441fc3f73790bc8447cb454362dc9.tar.gz |
gltestsrc: fix shaders ref counting
The gltestsrc element uses two shaders: color_shader and snow_shader.
Those are alternatively assigned to the SrcShader->shader pointer and
their reference was transferred to it. Only the SrcShader->shader was
unreffed (in _src_shader_deinit()) so only one shader was properly
freed, the other one was leaked.
Fixed this by giving an extra ref to SrcShader->shader and unreffing the
2 shaders in _src_smpte_free().
https://bugzilla.gnome.org/show_bug.cgi?id=766661
Diffstat (limited to 'ext/gl')
-rw-r--r-- | ext/gl/gltestsrc.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ext/gl/gltestsrc.c b/ext/gl/gltestsrc.c index 457f1c347..80e3c550a 100644 --- a/ext/gl/gltestsrc.c +++ b/ext/gl/gltestsrc.c @@ -494,7 +494,9 @@ _src_smpte_init (gpointer impl, GstGLContext * context, GstVideoInfo * v_info) src->base.attributes[1].offset = 4 * sizeof (gfloat); src->base.attributes[1].stride = sizeof (struct XYZWRGB); - src->base.shader = src->color_shader; + if (src->base.shader) + gst_object_unref (src->base.shader); + src->base.shader = gst_object_ref (src->color_shader); src->base.vertices = (gfloat *) coord; src->base.vertices_size = sizeof (struct XYZWRGB) * N_QUADS * 4; src->base.indices = plane_indices; @@ -510,7 +512,9 @@ _src_smpte_fill_bound_fbo (gpointer impl) gint attr_color_position = -1; src->base.n_attributes = 2; - src->base.shader = src->color_shader; + if (src->base.shader) + gst_object_unref (src->base.shader); + src->base.shader = gst_object_ref (src->color_shader); src->base.n_indices = (N_QUADS - 1) * 6; src->base.index_offset = 0; if (!_src_shader_fill_bound_fbo (impl)) @@ -519,7 +523,9 @@ _src_smpte_fill_bound_fbo (gpointer impl) src->base.attributes[0].location = src->attr_snow_position; src->base.n_attributes = 1; - src->base.shader = src->snow_shader; + if (src->base.shader) + gst_object_unref (src->base.shader); + src->base.shader = gst_object_ref (src->snow_shader); src->base.n_indices = 6; src->base.index_offset = (N_QUADS - 1) * 6 * sizeof (gushort); gst_gl_shader_use (src->snow_shader); @@ -546,6 +552,11 @@ _src_smpte_free (gpointer impl) g_free ((gpointer) src->base.vertices); g_free ((gpointer) src->base.indices); + if (src->snow_shader) + gst_object_unref (src->snow_shader); + if (src->color_shader) + gst_object_unref (src->color_shader); + g_free (impl); } |