wrappercamerabinsrc: Don't unset the video-source property on pipeline start

check_and_replace_src() was setting self->app_vid_src to NULL, which
means that an app setting the video-source property, and then starting,
stopping and re-starting the pipeline (ie to make changes to the
video-source-filter property) would after the restart no longer have
a video-source.

This patch fixes this by making gst_camerabin_setup_default_element return a
ref to the passed in user_element, rather then returning the user_element as
is, so that that ref can be passed on to the bin, and the app_vid_src ref
stays valid.

https://bugzilla.gnome.org/show_bug.cgi?id=701915
This commit is contained in:
Hans de Goede 2013-06-10 10:05:56 +02:00 committed by Sebastian Dröge
parent aad0992ae6
commit 8dc7fae455
2 changed files with 8 additions and 11 deletions

View file

@ -172,11 +172,11 @@ gst_camerabin_create_and_add_element (GstBin * bin, const gchar * elem_name,
return new_elem;
}
/* try to change the state of an element. This function returns the element when
* the state change could be performed. When this function returns NULL an error
* occured and the element is unreffed if @unref is TRUE. */
/* try to change the state of an element. This function returns the element
* when the state change could be performed. When this function returns NULL
* an error occured and the element is unreffed. */
static GstElement *
try_element (GstElement * bin, GstElement * element, gboolean unref)
try_element (GstElement * bin, GstElement * element)
{
GstStateChangeReturn ret;
@ -185,8 +185,7 @@ try_element (GstElement * bin, GstElement * element, gboolean unref)
if (ret == GST_STATE_CHANGE_FAILURE) {
GST_DEBUG_OBJECT (bin, "failed state change..");
gst_element_set_state (element, GST_STATE_NULL);
if (unref)
gst_object_unref (element);
gst_object_unref (element);
element = NULL;
}
}
@ -202,18 +201,18 @@ gst_camerabin_setup_default_element (GstBin * bin, GstElement * user_elem,
if (user_elem) {
GST_DEBUG_OBJECT (bin, "trying configured element");
elem = try_element (GST_ELEMENT_CAST (bin), user_elem, FALSE);
elem = try_element (GST_ELEMENT_CAST (bin), gst_object_ref (user_elem));
} else {
/* only try fallback if no specific sink was chosen */
GST_DEBUG_OBJECT (bin, "trying %s", auto_elem_name);
elem = gst_element_factory_make (auto_elem_name, instance_name);
elem = try_element (GST_ELEMENT_CAST (bin), elem, TRUE);
elem = try_element (GST_ELEMENT_CAST (bin), elem);
if (elem == NULL) {
/* if default sink from config.h is different then try it too */
if (strcmp (default_elem_name, auto_elem_name)) {
GST_DEBUG_OBJECT (bin, "trying %s", default_elem_name);
elem = gst_element_factory_make (default_elem_name, instance_name);
elem = try_element (GST_ELEMENT_CAST (bin), elem, TRUE);
elem = try_element (GST_ELEMENT_CAST (bin), elem);
}
}
}

View file

@ -489,8 +489,6 @@ check_and_replace_src (GstWrapperCameraBinSrc * self)
}
}
}
/* we lost the reference */
self->app_vid_src = NULL;
/* we listen for changes to max-zoom in the video src so that
* we can proxy them to the basecamerasrc property */