[704/906] Use gst_object_[un]ref so we can get refcounts in the log

This commit is contained in:
Matthew Waters 2013-06-13 14:36:41 +10:00 committed by Tim-Philipp Müller
parent 9e7af77dc8
commit 761bc0156a
9 changed files with 76 additions and 31 deletions

View file

@ -51,6 +51,7 @@ struct _GstGLBufferPoolPrivate
};
static void gst_gl_buffer_pool_finalize (GObject * object);
static void gst_gl_buffer_pool_dispose (GObject * object);
GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_BUFFER_POOL);
#define GST_CAT_DEFAULT GST_CAT_GL_BUFFER_POOL
@ -225,6 +226,7 @@ gst_gl_buffer_pool_class_init (GstGLBufferPoolClass * klass)
g_type_class_add_private (klass, sizeof (GstGLBufferPoolPrivate));
gobject_class->finalize = gst_gl_buffer_pool_finalize;
gobject_class->dispose = gst_gl_buffer_pool_dispose;
gstbufferpool_class->get_options = gst_gl_buffer_pool_get_options;
gstbufferpool_class->set_config = gst_gl_buffer_pool_set_config;
@ -237,6 +239,19 @@ gst_gl_buffer_pool_init (GstGLBufferPool * pool)
pool->priv = GST_GL_BUFFER_POOL_GET_PRIVATE (pool);
}
static void
gst_gl_buffer_pool_dispose (GObject * object)
{
GstGLBufferPool *pool = GST_GL_BUFFER_POOL_CAST (object);
if (pool->display) {
gst_object_unref (pool->display);
pool->display = NULL;
}
G_OBJECT_CLASS (gst_gl_buffer_pool_parent_class)->dispose (object);
}
static void
gst_gl_buffer_pool_finalize (GObject * object)
{

View file

@ -285,7 +285,7 @@ gst_gl_download_new (GstGLDisplay * display)
download = g_object_new (GST_TYPE_GL_DOWNLOAD, NULL);
download->display = g_object_ref (display);
download->display = gst_object_ref (display);
priv = download->priv;
#if GST_GL_HAVE_OPENGL
@ -337,16 +337,18 @@ gst_gl_download_finalize (GObject * object)
download->depth_buffer = 0;
}
if (download->shader) {
g_object_unref (G_OBJECT (download->shader));
gst_object_unref (download->shader);
download->shader = NULL;
}
if (download->display) {
g_object_unref (G_OBJECT (download->display));
gst_object_unref (download->display);
download->display = NULL;
}
g_mutex_clear (&download->lock);
G_OBJECT_CLASS (gst_gl_download_parent_class)->finalize (object);
}
static inline gboolean
@ -832,7 +834,7 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
gst_gl_display_set_error (display, "%s", error->message);
g_error_free (error);
gst_gl_display_clear_shader (display);
g_object_unref (G_OBJECT (shader));
gst_object_unref (shader);
return FALSE;
}

View file

@ -220,7 +220,7 @@ gst_gl_filter_reset (GstGLFilter * filter)
}
//blocking call, delete the FBO
gst_gl_display_del_fbo (filter->display, filter->fbo, filter->depthbuffer);
g_object_unref (filter->display);
gst_object_unref (filter->display);
filter->display = NULL;
}
@ -251,7 +251,7 @@ gst_gl_filter_start (GstBaseTransform * bt)
if (G_VALUE_HOLDS_POINTER (id_value))
/* at least one gl element is after in our gl chain */
filter->display =
g_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
gst_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
else {
GstGLWindow *window;
GError *error = NULL;
@ -260,7 +260,7 @@ gst_gl_filter_start (GstBaseTransform * bt)
filter->display = gst_gl_display_new ();
window = gst_gl_window_new (filter->display);
gst_gl_display_set_window (filter->display, window);
g_object_unref (window);
gst_object_unref (window);
if (!gst_gl_window_create_context (window, 0, &error)) {
GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND,
@ -1001,6 +1001,9 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
gst_gl_upload_perform_with_data (filter->upload, in_tex, in_frame.data);
}
GST_DEBUG ("calling filter_texture with textures in:%i out:%i", in_tex,
out_tex);
g_assert (filter_class->filter_texture);
ret = filter_class->filter_texture (filter, in_tex, out_tex);

View file

@ -460,7 +460,7 @@ gst_gl_mixer_child_proxy_get_child_by_index (GstChildProxy * child_proxy,
GST_GL_MIXER_LOCK (mix);
if ((obj = g_slist_nth_data (mix->sinkpads, index)))
g_object_ref (obj);
gst_object_ref (obj);
GST_GL_MIXER_UNLOCK (mix);
return obj;
}
@ -933,7 +933,7 @@ gst_gl_mixer_activate (GstGLMixer * mix, gboolean activate)
id_value = gst_structure_get_value (structure, "gstgldisplay");
if (G_VALUE_HOLDS_POINTER (id_value))
mix->display =
g_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
gst_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
else {
GstGLWindow *window;
GError *error = NULL;
@ -942,7 +942,7 @@ gst_gl_mixer_activate (GstGLMixer * mix, gboolean activate)
mix->display = gst_gl_display_new ();
window = gst_gl_window_new (mix->display);
gst_gl_display_set_window (mix->display, window);
g_object_unref (window);
gst_object_unref (window);
if (!gst_gl_window_create_context (window, 0, &error)) {
GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
@ -2140,7 +2140,7 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
mix->depthbuffer = 0;
}
if (mix->download) {
g_object_unref (mix->download);
gst_object_unref (mix->download);
mix->download = NULL;
}
@ -2148,7 +2148,7 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
GstGLMixerPad *pad = (GstGLMixerPad *) (walk->data);
if (pad->upload) {
g_object_unref (pad->upload);
gst_object_unref (pad->upload);
pad->upload = NULL;
}
@ -2156,7 +2156,7 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
}
if (mix->display) {
g_object_unref (mix->display);
gst_object_unref (mix->display);
mix->display = NULL;
}
break;

View file

@ -92,6 +92,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_gl_shader_debug);
GST_DEBUG_CATEGORY_INIT (gst_gl_shader_debug, "glshader", 0, "shader");
G_DEFINE_TYPE_WITH_CODE (GstGLShader, gst_gl_shader, G_TYPE_OBJECT, DEBUG_INIT);
static void
gst_gl_shader_dispose (GObject * object)
{
GstGLShader *shader;
shader = GST_GL_SHADER (object);
if (shader->display) {
gst_object_unref (shader->display);
shader->display = NULL;
}
G_OBJECT_CLASS (gst_gl_shader_parent_class)->dispose (object);
}
static void
gst_gl_shader_finalize (GObject * object)
{
@ -181,6 +196,7 @@ gst_gl_shader_class_init (GstGLShaderClass * klass)
g_type_class_add_private (klass, sizeof (GstGLShaderPrivate));
obj_class->finalize = gst_gl_shader_finalize;
obj_class->dispose = gst_gl_shader_dispose;
obj_class->set_property = gst_gl_shader_set_property;
obj_class->get_property = gst_gl_shader_get_property;
@ -332,7 +348,7 @@ gst_gl_shader_new (GstGLDisplay * display)
g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL);
shader = g_object_new (GST_GL_TYPE_SHADER, NULL);
shader->display = display;
shader->display = gst_object_ref (display);
if (!_fill_vtable (shader, display))
return NULL;

View file

@ -271,7 +271,7 @@ gst_gl_upload_new (GstGLDisplay * display)
upload = g_object_new (GST_TYPE_GL_UPLOAD, NULL);
upload->display = g_object_ref (display);
upload->display = gst_object_ref (display);
priv = upload->priv;
g_mutex_init (&upload->lock);
@ -322,14 +322,16 @@ gst_gl_upload_finalize (GObject * object)
upload->depth_buffer = 0;
}
if (upload->shader) {
g_object_unref (G_OBJECT (upload->shader));
gst_object_unref (upload->shader);
upload->shader = NULL;
}
if (upload->display) {
g_object_unref (G_OBJECT (upload->display));
gst_object_unref (upload->display);
upload->display = NULL;
}
G_OBJECT_CLASS (gst_gl_upload_parent_class)->finalize (object);
}
/**
@ -637,7 +639,7 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
gst_gl_display_set_error (display, "%s", error->message);
g_error_free (error);
gst_gl_display_clear_shader (display);
g_object_unref (G_OBJECT (shader));
gst_object_unref (shader);
return FALSE;
}

View file

@ -52,6 +52,8 @@ static GLuint gen_texture_width;
static GLuint gen_texture_height;
static GstVideoFormat gen_texture_video_format;
static GLuint *del_texture;
/* filter gen fbo */
static GLuint gen_fbo_width;
static GLuint gen_fbo_height;
@ -187,9 +189,9 @@ gst_gl_display_gen_texture_thread (GstGLDisplay * display, GLuint * pTexture,
}
void
gst_gl_display_del_texture_thread (GstGLDisplay * display, GLuint * pTexture)
gst_gl_display_del_texture_window_cb (GstGLDisplay * display)
{
//glDeleteTextures (1, pTexture);
glDeleteTextures (1, del_texture);
}
/* called in the gl thread */
@ -258,10 +260,19 @@ gst_gl_display_gen_texture (GstGLDisplay * display, GLuint * pTexture,
void
gst_gl_display_del_texture (GstGLDisplay * display, GLuint * pTexture)
{
GstGLWindow *window;
gst_gl_display_lock (display);
if (*pTexture) {
gst_gl_display_del_texture_thread (display, pTexture);
window = gst_gl_display_get_window_unlocked (display);
if (gst_gl_window_is_running (window) && *pTexture) {
del_texture = pTexture;
gst_gl_window_send_message (window,
GST_GL_WINDOW_CB (gst_gl_display_del_texture_window_cb), display);
}
gst_object_unref (window);
gst_gl_display_unlock (display);
}
@ -689,7 +700,7 @@ _gen_shader (GstGLDisplay * display)
g_error_free (error);
error = NULL;
gst_gl_display_clear_shader (display);
g_object_unref (G_OBJECT (gen_shader));
gst_object_unref (gen_shader);
gen_shader = NULL;
}
}
@ -707,7 +718,7 @@ _del_shader (GstGLDisplay * display)
GST_TRACE ("Deleting shader %" GST_PTR_FORMAT, del_shader);
if (del_shader) {
g_object_unref (G_OBJECT (del_shader));
gst_object_unref (del_shader);
del_shader = NULL;
}
}

View file

@ -296,10 +296,10 @@ gst_gl_window_quit (GstGLWindow * window, GstGLWindowCB callback, gpointer data)
GST_INFO ("quit sent to gl window loop");
GST_GL_WINDOW_UNLOCK (window);
g_cond_wait (&window->priv->cond_destroy_context, &window->priv->render_lock);
GST_INFO ("quit received from gl window");
GST_GL_WINDOW_UNLOCK (window);
}
void
@ -743,10 +743,6 @@ _gst_gl_window_thread_create_context (GstGLWindow * window)
window->priv->alive = FALSE;
// g_object_unref (G_OBJECT (display->gl_window));
// display->gl_window = NULL;
g_cond_signal (&window->priv->cond_destroy_context);
g_mutex_unlock (&window->priv->render_lock);

View file

@ -43,7 +43,7 @@ setup (void)
void
teardown (void)
{
g_object_unref (display);
gst_object_unref (display);
}
GST_START_TEST (test_basic)