autoconvert: subelement can only be change with stream lock held

It was already the case, now be more explicit about that, and remove useless
lock/ref/unlock/unref dances.
This commit is contained in:
Olivier Crête 2014-05-07 19:54:46 -04:00
parent 606ff3debd
commit 9eeef09c80
2 changed files with 12 additions and 24 deletions

View file

@ -719,7 +719,6 @@ static gboolean
gst_auto_convert_sink_setcaps (GstAutoConvert * autoconvert, GstCaps * caps) gst_auto_convert_sink_setcaps (GstAutoConvert * autoconvert, GstCaps * caps)
{ {
GList *elem; GList *elem;
GstElement *subelement;
GstCaps *other_caps = NULL; GstCaps *other_caps = NULL;
GList *factories; GList *factories;
GstCaps *current_caps; GstCaps *current_caps;
@ -735,9 +734,7 @@ gst_auto_convert_sink_setcaps (GstAutoConvert * autoconvert, GstCaps * caps)
gst_caps_unref (current_caps); gst_caps_unref (current_caps);
} }
subelement = gst_auto_convert_get_subelement (autoconvert); if (autoconvert->current_subelement) {
if (subelement) {
if (gst_pad_peer_query_accept_caps (autoconvert->current_internal_srcpad, if (gst_pad_peer_query_accept_caps (autoconvert->current_internal_srcpad,
caps)) { caps)) {
/* If we can set the new caps on the current element, /* If we can set the new caps on the current element,
@ -745,20 +742,16 @@ gst_auto_convert_sink_setcaps (GstAutoConvert * autoconvert, GstCaps * caps)
*/ */
GST_DEBUG_OBJECT (autoconvert, "Could set %s:%s to %" GST_PTR_FORMAT, GST_DEBUG_OBJECT (autoconvert, "Could set %s:%s to %" GST_PTR_FORMAT,
GST_DEBUG_PAD_NAME (autoconvert->current_internal_srcpad), caps); GST_DEBUG_PAD_NAME (autoconvert->current_internal_srcpad), caps);
gst_object_unref (subelement);
goto get_out; goto get_out;
} else { } else {
/* If the current element doesn't work, /* If the current element doesn't work,
* then we remove the current element before finding a new one. * then we remove the current element before finding a new one.
*/ */
GST_AUTOCONVERT_LOCK (autoconvert); GST_AUTOCONVERT_LOCK (autoconvert);
if (autoconvert->current_subelement == subelement) { g_clear_object (&autoconvert->current_subelement);
g_clear_object (&autoconvert->current_subelement); g_clear_object (&autoconvert->current_internal_sinkpad);
g_clear_object (&autoconvert->current_internal_sinkpad); g_clear_object (&autoconvert->current_internal_srcpad);
g_clear_object (&autoconvert->current_internal_srcpad);
}
GST_AUTOCONVERT_UNLOCK (autoconvert); GST_AUTOCONVERT_UNLOCK (autoconvert);
gst_object_unref (subelement);
} }
} }
@ -939,20 +932,13 @@ gst_auto_convert_sink_chain (GstPad * pad, GstObject * parent,
{ {
GstFlowReturn ret = GST_FLOW_NOT_NEGOTIATED; GstFlowReturn ret = GST_FLOW_NOT_NEGOTIATED;
GstAutoConvert *autoconvert = GST_AUTO_CONVERT (parent); GstAutoConvert *autoconvert = GST_AUTO_CONVERT (parent);
GstPad *internal_srcpad;
internal_srcpad = gst_auto_convert_get_internal_srcpad (autoconvert); if (autoconvert->current_internal_srcpad) {
if (internal_srcpad) { ret = gst_pad_push (autoconvert->current_internal_srcpad, buffer);
ret = gst_pad_push (internal_srcpad, buffer); if (ret != GST_FLOW_OK)
gst_object_unref (internal_srcpad);
if (ret != GST_FLOW_OK) {
GstElement *child = gst_auto_convert_get_subelement (autoconvert);
GST_DEBUG_OBJECT (autoconvert, GST_DEBUG_OBJECT (autoconvert,
"Child element %" GST_PTR_FORMAT "returned flow %s", child, "Child element %" GST_PTR_FORMAT "returned flow %s",
gst_flow_get_name (ret)); autoconvert->current_subelement, gst_flow_get_name (ret));
if (child)
gst_object_unref (child);
}
} else { } else {
GST_ERROR_OBJECT (autoconvert, "Got buffer without an negotiated element," GST_ERROR_OBJECT (autoconvert, "Got buffer without an negotiated element,"
" returning not-negotiated"); " returning not-negotiated");

View file

@ -48,7 +48,9 @@ struct _GstAutoConvert
GstPad *srcpad; GstPad *srcpad;
/* Have to be set all at once /* Have to be set all at once
* Protected by the object lock */ * Protected by the object lock and the stream lock
* Both must be held to modify these
*/
GstElement *current_subelement; GstElement *current_subelement;
GstPad *current_internal_srcpad; GstPad *current_internal_srcpad;
GstPad *current_internal_sinkpad; GstPad *current_internal_sinkpad;