splitmuxsink: Make sure flushing doesn't block

* Trying to disconnect a stream from a running splitmuxsink by flushing
  it results in the FLUSH_START blocking in the stream queue's
  gst_pad_pause_task because the flush did not unblock
  complete_or_wait_on_out, so add a check for ctx->flushing there.

* Add a GST_SPLITMUX_BROADCAST_INPUT so check_completed_gop notices
  flushing changed and the incoming push is unblocked.

* Pass the FLUSH_STOP along to the muxer without waiting.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/687>
This commit is contained in:
Jan Alexander Steffens (heftig) 2020-07-31 13:50:13 +02:00 committed by GStreamer Merge Bot
parent af9e66d7a5
commit 28a616f693

View file

@ -1331,7 +1331,7 @@ complete_or_wait_on_out (GstSplitMuxSink * splitmux, MqStreamCtx * ctx)
} else {
GST_SPLITMUX_WAIT_OUTPUT (splitmux);
}
} while (splitmux->output_state ==
} while (!ctx->flushing && splitmux->output_state ==
SPLITMUX_OUTPUT_STATE_AWAITING_COMMAND);
/* loop and re-check the state */
continue;
@ -1551,7 +1551,7 @@ handle_mq_output (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx)
if (info->type & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM ||
info->type & GST_PAD_PROBE_TYPE_EVENT_FLUSH) {
GstEvent *event = gst_pad_probe_info_get_event (info);
gboolean locked = FALSE;
gboolean locked = FALSE, wait = !ctx->is_reference;
GST_LOG_OBJECT (pad, "Event %" GST_PTR_FORMAT, event);
@ -1570,12 +1570,14 @@ handle_mq_output (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx)
if (ctx->is_reference)
splitmux->queued_keyframes = 0;
ctx->flushing = FALSE;
wait = FALSE;
break;
case GST_EVENT_FLUSH_START:
GST_SPLITMUX_LOCK (splitmux);
locked = TRUE;
GST_LOG_OBJECT (pad, "Flush start");
ctx->flushing = TRUE;
GST_SPLITMUX_BROADCAST_INPUT (splitmux);
GST_SPLITMUX_BROADCAST_OUTPUT (splitmux);
break;
case GST_EVENT_EOS:
@ -1691,7 +1693,7 @@ handle_mq_output (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx)
* until the muxer / sink are ready for it */
if (!locked)
GST_SPLITMUX_LOCK (splitmux);
if (!ctx->is_reference)
if (wait)
complete_or_wait_on_out (splitmux, ctx);
GST_SPLITMUX_UNLOCK (splitmux);