From 7e9fb16c4858d7384641075949d5642c3beaa8fc Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Thu, 10 Feb 2011 16:00:03 +0200 Subject: [PATCH] camerabin: application element memory leak fixes If videobin/imagebin was never set to READY state the ownership of elements created and set by application were never taken by bin and therefore gst_object_sink is called for these elements before unreffing (they may still be in floating state and not unreffed properly without sinking first) --- gst/camerabin/camerabinimage.c | 8 ++++++++ gst/camerabin/camerabinvideo.c | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/gst/camerabin/camerabinimage.c b/gst/camerabin/camerabinimage.c index 8b94d7d22a..2aa858d883 100644 --- a/gst/camerabin/camerabinimage.c +++ b/gst/camerabin/camerabinimage.c @@ -196,7 +196,14 @@ gst_camerabin_image_dispose (GstCameraBinImage * img) } + /* Note: if imagebin was never set to READY state the + ownership of elements created by application were never + taken by bin and therefore gst_object_sink is called for + these elements (they may still be in floating state + and not unreffed properly without sinking first) + */ if (img->app_enc) { + gst_object_sink (img->app_enc); GST_LOG_OBJECT (img, "disposing %s with refcount %d", GST_ELEMENT_NAME (img->app_enc), GST_OBJECT_REFCOUNT_VALUE (img->app_enc)); @@ -205,6 +212,7 @@ gst_camerabin_image_dispose (GstCameraBinImage * img) } if (img->post) { + gst_object_sink (img->post); GST_LOG_OBJECT (img, "disposing %s with refcount %d", GST_ELEMENT_NAME (img->post), GST_OBJECT_REFCOUNT_VALUE (img->post)); gst_object_unref (img->post); diff --git a/gst/camerabin/camerabinvideo.c b/gst/camerabin/camerabinvideo.c index 9100518767..257eed31f2 100644 --- a/gst/camerabin/camerabinvideo.c +++ b/gst/camerabin/camerabinvideo.c @@ -215,27 +215,38 @@ gst_camerabin_video_dispose (GstCameraBinVideo * vid) vid->vid_sink_probe_id = 0; } + /* Note: if videobin was never set to READY state the + ownership of elements created by application were never + taken by bin and therefore gst_object_sink is called for + these elements (they may still be in floating state + and not unreffed properly without sinking first) + */ if (vid->app_post) { + gst_object_sink (vid->app_post); gst_object_unref (vid->app_post); vid->app_post = NULL; } if (vid->app_vid_enc) { + gst_object_sink (vid->app_vid_enc); gst_object_unref (vid->app_vid_enc); vid->app_vid_enc = NULL; } if (vid->app_aud_enc) { + gst_object_sink (vid->app_aud_enc); gst_object_unref (vid->app_aud_enc); vid->app_aud_enc = NULL; } if (vid->app_aud_src) { + gst_object_sink (vid->app_aud_src); gst_object_unref (vid->app_aud_src); vid->app_aud_src = NULL; } if (vid->app_mux) { + gst_object_sink (vid->app_mux); gst_object_unref (vid->app_mux); vid->app_mux = NULL; }