validate: Accept pad return FLUSHING when the element is being teared down

In the case and element is in READY or is going to READY state, it can
always return GST_FLOW_FLUSHING.

Avoid a race where a demuxer sinkpad has not been set to FLUSHING when we are
still processing a buffer but downstream is already FLUSHING and thus
the demuxer is already returning FLUSHING.
This commit is contained in:
Thibault Saunier 2016-03-22 11:19:42 +01:00
parent 621bda9b62
commit 4f553b7c78
2 changed files with 14 additions and 5 deletions

View file

@ -1198,7 +1198,7 @@ _combine_flows (GstFlowReturn ret1, GstFlowReturn ret2)
static void
gst_validate_pad_monitor_check_aggregated_return (GstValidatePadMonitor *
monitor, GstFlowReturn ret)
monitor, GstObject * parent, GstFlowReturn ret)
{
GstIterator *iter;
gboolean done;
@ -1250,13 +1250,22 @@ gst_validate_pad_monitor_check_aggregated_return (GstValidatePadMonitor *
return;
}
if (aggregated == GST_FLOW_OK || aggregated == GST_FLOW_EOS) {
/* those are acceptable situations */
GstState state, pending;
/* those are acceptable situations */
if (GST_PAD_IS_FLUSHING (pad) && ret == GST_FLOW_FLUSHING) {
/* pad is flushing, always acceptable to return flushing */
return;
}
gst_element_get_state (GST_ELEMENT (parent), &state, &pending, 0);
if (ret == GST_FLOW_FLUSHING && (state < GST_STATE_PAUSED
|| pending < GST_STATE_PAUSED)) {
/* Element is being teared down, accept FLOW_FLUSHING */
return;
}
if (monitor->is_eos && ret == GST_FLOW_EOS) {
/* this element received eos and returned eos */
return;
@ -2071,7 +2080,7 @@ gst_validate_pad_monitor_chain_func (GstPad * pad, GstObject * parent,
mark_pads_eos (pad_monitor);
}
if (PAD_PARENT_IS_DEMUXER (pad_monitor))
gst_validate_pad_monitor_check_aggregated_return (pad_monitor, ret);
gst_validate_pad_monitor_check_aggregated_return (pad_monitor, parent, ret);
GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK (pad_monitor);

View file

@ -158,7 +158,7 @@ _bus_handler (GstBus * bus, GstMessage * message,
if (percent == 100) {
/* a 100% message means buffering is done */
gst_validate_printf (NULL, "Done buffering\n");
gst_validate_printf (NULL, "\nDone buffering\n");
if (monitor->buffering) {
monitor->print_pos_srcid =
g_timeout_add (PRINT_POSITION_TIMEOUT,
@ -169,7 +169,7 @@ _bus_handler (GstBus * bus, GstMessage * message,
/* buffering... */
if (!monitor->buffering) {
monitor->buffering = TRUE;
gst_validate_printf (NULL, "Start buffering\n");
gst_validate_printf (NULL, "\nStart buffering\n");
if (monitor->print_pos_srcid
&& g_source_remove (monitor->print_pos_srcid)) {
monitor->print_pos_srcid = 0;