typefind: Allow caps query in "have-type" signal handlers

If an application calls gst_pad_query_caps from its "have-type" signal handler,
then the query fails because typefind->caps has not been set yet.

This patch sets typefind->caps in the object method handler, before the signal
handlers are called.

https://bugzilla.gnome.org/show_bug.cgi?id=763491
This commit is contained in:
Romain Picard 2016-03-15 16:37:33 +01:00 committed by Tim-Philipp Müller
parent 24b7a8fe18
commit d1f87286ab

View file

@ -203,9 +203,6 @@ gst_type_find_element_have_type (GstTypeFindElement * typefind,
event = gst_event_new_caps (caps);
}
if (typefind->caps)
gst_caps_unref (typefind->caps);
typefind->caps = gst_caps_ref (caps);
GST_OBJECT_UNLOCK (typefind);
gst_pad_push_event (typefind->src, event);
@ -217,6 +214,15 @@ gst_type_find_element_emit_have_type (GstTypeFindElement * typefind,
{
GstEvent *event;
/* Update caps field immediatly so that caps queries and properties can be
* honored in all "have-type" signal handlers.
*/
GST_OBJECT_LOCK (typefind);
if (typefind->caps)
gst_caps_unref (typefind->caps);
typefind->caps = gst_caps_ref (caps);
GST_OBJECT_UNLOCK (typefind);
/* Only store the caps event at this point. We give signal handlers
* the chance to look at the caps before they are sent downstream.
* They are only forwarded downstream later in the default signal