diff options
author | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2010-12-29 13:18:37 -0300 |
---|---|---|
committer | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2010-12-29 13:24:06 -0300 |
commit | 95597d8f0e4c6813732d3d067236f35d3debf552 (patch) | |
tree | f03b45c5883af1174dc8032fd87ebd47dec5ca2d | |
parent | 87c5c7a08bdb2ff479ffa307bc90a43d45191f08 (diff) | |
download | gstreamer-plugins-bad-95597d8f0e4c6813732d3d067236f35d3debf552.tar.gz |
camerabin2: Various leak fixes
Various leak fixes and some code reorganization
-rw-r--r-- | gst/camerabin2/gstwrappercamerabinsrc.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/gst/camerabin2/gstwrappercamerabinsrc.c b/gst/camerabin2/gstwrappercamerabinsrc.c index 74d27fe79..ebf2d8e87 100644 --- a/gst/camerabin2/gstwrappercamerabinsrc.c +++ b/gst/camerabin2/gstwrappercamerabinsrc.c @@ -57,6 +57,13 @@ static void set_capsfilter_caps (GstWrapperCameraBinSrc * self, static void gst_wrapper_camera_bin_src_dispose (GObject * object) { + GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (object); + + if (self->app_vid_src) { + gst_object_unref (self->app_vid_src); + self->app_vid_src = NULL; + } + G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -116,7 +123,6 @@ gst_wrapper_camera_bin_reset_video_src_caps (GstWrapperCameraBinSrc * self, GstCaps * caps) { GST_DEBUG_OBJECT (self, "Resetting src caps to %" GST_PTR_FORMAT, caps); - /* TODO this won't work on NULL */ if (self->src_vid_src) { gst_element_set_state (self->src_vid_src, GST_STATE_NULL); set_capsfilter_caps (self, caps); @@ -268,6 +274,8 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc) goto done; } } + /* we lost the reference */ + self->app_vid_src = NULL; /* add a buffer probe to the src elemento to drop EOS from READY->NULL */ { @@ -302,6 +310,7 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc) /* viewfinder pad */ vf_pad = gst_element_get_request_pad (tee, "src%d"); g_object_set (tee, "alloc-pad", vf_pad, NULL); + gst_object_unref (vf_pad); /* the viewfinder should always work, so we add some converters to it */ if (!gst_camerabin_create_and_add_element (cbin, "ffmpegcolorspace")) @@ -309,9 +318,6 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc) if (!(videoscale = gst_camerabin_create_and_add_element (cbin, "videoscale"))) goto done; - gst_object_unref (vf_pad); - vf_pad = gst_element_get_static_pad (videoscale, "src"); - /* image/video pad from tee */ tee_capture_pad = gst_element_get_request_pad (tee, "src%d"); @@ -325,6 +331,7 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc) gst_pad_link (tee_capture_pad, pad); gst_object_unref (pad); } + gst_object_unref (tee_capture_pad); /* Create the 2 output pads for video and image */ self->outsel_vidpad = @@ -350,8 +357,10 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc) NULL); } - /* hook-up the vf ghostpads */ + /* hook-up the vf ghostpad */ + vf_pad = gst_element_get_static_pad (videoscale, "src"); gst_ghost_pad_set_target (GST_GHOST_PAD (self->vfsrc), vf_pad); + gst_object_unref (vf_pad); gst_pad_set_active (self->vfsrc, TRUE); gst_pad_set_active (self->imgsrc, TRUE); /* XXX ??? */ @@ -446,8 +455,10 @@ adapt_image_capture (GstWrapperCameraBinSrc * self, GstCaps * in_caps) } /* Update capsfilters */ - gst_caps_replace (&self->image_capture_caps, - gst_caps_new_full (new_st, NULL)); + if (self->image_capture_caps) { + gst_caps_unref (self->image_capture_caps); + } + self->image_capture_caps = gst_caps_new_full (new_st, NULL); set_capsfilter_caps (self, self->image_capture_caps); /* Adjust the capsfilter before crop and videoscale elements if necessary */ @@ -830,7 +841,7 @@ gst_wrapper_camera_bin_src_start_capture (GstBaseCameraSrc * camerasrc) { GstWrapperCameraBinSrc *src = GST_WRAPPER_CAMERA_BIN_SRC (camerasrc); - /* TODO shoud we access this directly? Maybe a macro is better? */ + /* TODO should we access this directly? Maybe a macro is better? */ if (src->mode == MODE_IMAGE) { start_image_capture (src); src->image_capture_count = 1; |