if (stream->download_request)
download_request_unref (stream->download_request);
- stream->cancelled = TRUE;
g_clear_error (&stream->last_error);
gst_adaptive_demux2_stream_fragment_clear (&stream->fragment);
gst_pad_send_event (stream->parsebin_sink, buffer_gap);
}
- if (G_UNLIKELY (stream->cancelled)) {
+ if (G_UNLIKELY (stream->state == GST_ADAPTIVE_DEMUX2_STREAM_STATE_STOPPED)) {
GST_LOG_OBJECT (demux, "Stream was cancelled");
return GST_FLOW_FLUSHING;
}
GstFlowReturn ret = GST_FLOW_OK;
/* do not make any changes if the stream is cancelled */
- if (G_UNLIKELY (stream->cancelled)) {
+ if (G_UNLIKELY (stream->state == GST_ADAPTIVE_DEMUX2_STREAM_STATE_STOPPED)) {
+ GST_DEBUG_OBJECT (stream, "Stream was stopped. Aborting");
gst_buffer_unref (buffer);
return GST_FLOW_FLUSHING;
}
if (ret == GST_FLOW_FLUSHING) {
/* do not make any changes if the stream is cancelled */
- if (G_UNLIKELY (stream->cancelled)) {
+ if (stream->state == GST_ADAPTIVE_DEMUX2_STREAM_STATE_STOPPED) {
+ GST_DEBUG_OBJECT (stream, "Stream was stopped. Aborting");
return ret;
}
}
guint last_status_code = request->status_code;
gboolean live;
+ if (stream->state != GST_ADAPTIVE_DEMUX2_STREAM_STATE_DOWNLOADING) {
+ GST_DEBUG_OBJECT (stream, "Stream state changed to %d. Aborting",
+ stream->state);
+ return;
+ }
+
stream->download_active = FALSE;
stream->last_status_code = last_status_code;
stream->download_active = FALSE;
- if (G_UNLIKELY (stream->cancelled))
+ if (stream->state != GST_ADAPTIVE_DEMUX2_STREAM_STATE_DOWNLOADING) {
+ GST_DEBUG_OBJECT (stream, "Stream state changed to %d. Aborting",
+ stream->state);
return;
+ }
GST_DEBUG_OBJECT (stream,
"Stream %p %s download for %s is complete with state %d",
gst_adaptive_demux2_stream_wants_manifest_update (demux);
return;
}
-
- if (stream->replaced)
- return;
}
gst_adaptive_demux2_stream_end_of_manifest (stream);
GST_ERROR_OBJECT (stream,
"Unexpected stream state EOS. The stream should not be running now.");
return FALSE;
+ case GST_ADAPTIVE_DEMUX2_STREAM_STATE_STOPPED:
+ /* The stream was stopped. Just finish up */
+ return FALSE;
default:
GST_ERROR_OBJECT (stream, "Unexpected stream state %d", stream->state);
g_assert_not_reached ();
case GST_FLOW_FLUSHING:
/* Flushing is normal, the target track might have been unselected */
- if (G_UNLIKELY (stream->cancelled))
- return FALSE;
-
+ GST_DEBUG_OBJECT (stream, "Got flushing return. Stopping callback.");
+ return FALSE;
default:
if (ret <= GST_FLOW_ERROR) {
GST_WARNING_OBJECT (demux, "Error while downloading fragment");
stream->state == GST_ADAPTIVE_DEMUX2_STREAM_STATE_RESTART) {
GST_LOG_OBJECT (stream, "Activating stream. Current state %d",
stream->state);
- stream->cancelled = FALSE;
- stream->replaced = FALSE;
stream->last_ret = GST_FLOW_OK;
if (stream->state == GST_ADAPTIVE_DEMUX2_STREAM_STATE_STOPPED)