summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2013-07-16 14:11:46 +0200
committerSebastian Dröge <slomo@circular-chaos.org>2013-07-16 14:11:46 +0200
commitc48b32379a16111833e77e6224fcf8ff7416cd65 (patch)
tree997fc79d07aae5a895f0a3c69b9970fc4460f7a2
parent8750d2d37b1a25ddd8dc486ca9c940e84a2ee7b0 (diff)
glimagesink: Fix some memory leaks and properly set up the buffer pool
-rw-r--r--gst-libs/gst/gl/x11/gstglwindow_x11.c2
-rw-r--r--gst/gl/gstglimagesink.c55
-rw-r--r--gst/gl/gstglimagesink.h2
3 files changed, 44 insertions, 15 deletions
diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.c b/gst-libs/gst/gl/x11/gstglwindow_x11.c
index 5bcde3e..a4f8a2c 100644
--- a/gst-libs/gst/gl/x11/gstglwindow_x11.c
+++ b/gst-libs/gst/gl/x11/gstglwindow_x11.c
@@ -415,9 +415,7 @@ gst_gl_window_x11_close (GstGLWindow * window)
//XCloseDisplay (window_x11->device);
GST_DEBUG ("display receiver closed");
- g_mutex_lock (&window_x11->disp_send_lock);
XCloseDisplay (window_x11->disp_send);
- g_mutex_unlock (&window_x11->disp_send_lock);
GST_DEBUG ("display sender closed");
}
diff --git a/gst/gl/gstglimagesink.c b/gst/gl/gstglimagesink.c
index 5d45983..758e13f 100644
--- a/gst/gl/gstglimagesink.c
+++ b/gst/gl/gstglimagesink.c
@@ -330,6 +330,11 @@ gst_glimage_sink_finalize (GObject * object)
glimage_sink->par = NULL;
}
+ if (glimage_sink->pool) {
+ gst_object_unref (glimage_sink->pool);
+ glimage_sink->pool = NULL;
+ }
+
g_free (glimage_sink->display_name);
GST_DEBUG ("finalized");
@@ -393,6 +398,16 @@ gst_glimage_sink_query (GstBaseSink * bsink, GstQuery * query)
return res;
}
+static void
+gst_glimage_sink_cleanup_glthread (GstGLImageSink * gl_sink)
+{
+#if GST_GL_HAVE_GLES2
+ if (gl_sink->redisplay_shader) {
+ gst_object_unref (gl_sink->redisplay_shader);
+ gl_sink->redisplay_shader = NULL;
+ }
+#endif
+}
/*
* GstElement methods
@@ -485,11 +500,20 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
glimage_sink->window_id = 0;
//but do not reset glimage_sink->new_window_id
+ if (glimage_sink->pool) {
+ gst_buffer_pool_set_active (glimage_sink->pool, FALSE);
+ gst_object_unref (glimage_sink->pool);
+ glimage_sink->pool = NULL;
+ }
+
GST_VIDEO_SINK_WIDTH (glimage_sink) = 1;
GST_VIDEO_SINK_HEIGHT (glimage_sink) = 1;
if (glimage_sink->display) {
GstGLWindow *window = gst_gl_display_get_window (glimage_sink->display);
+ gst_gl_window_send_message (window,
+ GST_GL_WINDOW_CB (gst_glimage_sink_cleanup_glthread), glimage_sink);
+
gst_gl_window_set_resize_callback (window, NULL, NULL, NULL);
gst_gl_window_set_draw_callback (window, NULL, NULL, NULL);
gst_gl_window_set_close_callback (window, NULL, NULL, NULL);
@@ -543,6 +567,8 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
gint display_par_n, display_par_d;
guint display_ratio_num, display_ratio_den;
GstVideoInfo vinfo;
+ GstStructure *structure;
+ GstBufferPool *newpool, *oldpool;
GST_DEBUG ("set caps with %" GST_PTR_FORMAT, caps);
@@ -608,6 +634,24 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
glimage_sink->info = vinfo;
+ newpool = gst_gl_buffer_pool_new (glimage_sink->display);
+ structure = gst_buffer_pool_get_config (newpool);
+ gst_buffer_pool_config_set_params (structure, caps, vinfo.size, 2, 0);
+ gst_buffer_pool_set_config (newpool, structure);
+
+ oldpool = glimage_sink->pool;
+ /* we don't activate the pool yet, this will be done by downstream after it
+ * has configured the pool. If downstream does not want our pool we will
+ * activate it when we render into it */
+ glimage_sink->pool = newpool;
+
+ /* unref the old sink */
+ if (oldpool) {
+ /* we don't deactivate, some elements might still be using it, it will
+ * be deactivated when the last ref is gone */
+ gst_object_unref (oldpool);
+ }
+
return TRUE;
}
@@ -1054,14 +1098,3 @@ gst_glimage_sink_redisplay (GstGLImageSink * gl_sink, GLuint texture,
return alive;
}
-
-void
-temp (GstGLImageSink * gl_sink)
-{
-#if GST_GL_HAVE_GLES2
- if (gl_sink->redisplay_shader) {
- gst_object_unref (gl_sink->redisplay_shader);
- gl_sink->redisplay_shader = NULL;
- }
-#endif
-}
diff --git a/gst/gl/gstglimagesink.h b/gst/gl/gstglimagesink.h
index 6d923fa..378afb6 100644
--- a/gst/gl/gstglimagesink.h
+++ b/gst/gl/gstglimagesink.h
@@ -81,8 +81,6 @@ struct _GstGLImageSink
GLuint redisplay_texture_height;
#if GST_GL_HAVE_GLES2
GstGLShader *redisplay_shader;
- gchar *redisplay_vertex_shader_str_gles2;
- gchar *redisplay_fragment_shader_str_gles2;
GLint redisplay_attr_position_loc;
GLint redisplay_attr_texture_loc;
#endif