mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 08:42:32 +00:00
adaptivedemux2: Handle return in seek handling
Various code path were repeating the same logic, and risk forgetting a lock release. Unify all of them Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
This commit is contained in:
parent
630eb61273
commit
adc07d77d5
1 changed files with 11 additions and 43 deletions
|
@ -2065,7 +2065,7 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
||||||
gint64 start, stop;
|
gint64 start, stop;
|
||||||
guint32 seqnum;
|
guint32 seqnum;
|
||||||
gboolean update;
|
gboolean update;
|
||||||
gboolean ret;
|
gboolean ret = FALSE;
|
||||||
GstSegment oldsegment;
|
GstSegment oldsegment;
|
||||||
GstEvent *flush_event;
|
GstEvent *flush_event;
|
||||||
|
|
||||||
|
@ -2113,9 +2113,7 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
||||||
GST_ERROR_OBJECT (demux,
|
GST_ERROR_OBJECT (demux,
|
||||||
"Instant rate change seeks only supported in the "
|
"Instant rate change seeks only supported in the "
|
||||||
"same direction, without flushing and position change");
|
"same direction, without flushing and position change");
|
||||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
goto unlock_return;
|
||||||
GST_API_UNLOCK (demux);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rate_multiplier = rate / demux->segment.rate;
|
rate_multiplier = rate / demux->segment.rate;
|
||||||
|
@ -2131,32 +2129,17 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
||||||
demux->instant_rate_multiplier = rate_multiplier;
|
demux->instant_rate_multiplier = rate_multiplier;
|
||||||
GST_ADAPTIVE_DEMUX_SEGMENT_UNLOCK (demux);
|
GST_ADAPTIVE_DEMUX_SEGMENT_UNLOCK (demux);
|
||||||
}
|
}
|
||||||
|
goto unlock_return;
|
||||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
|
||||||
GST_API_UNLOCK (demux);
|
|
||||||
gst_event_unref (event);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_adaptive_demux_can_seek (demux)) {
|
if (!gst_adaptive_demux_can_seek (demux))
|
||||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
goto unlock_return;
|
||||||
|
|
||||||
GST_API_UNLOCK (demux);
|
|
||||||
gst_event_unref (event);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We can only accept flushing seeks from this point onward */
|
/* We can only accept flushing seeks from this point onward */
|
||||||
if (!(flags & GST_SEEK_FLAG_FLUSH)) {
|
if (!(flags & GST_SEEK_FLAG_FLUSH)) {
|
||||||
GST_ERROR_OBJECT (demux,
|
GST_ERROR_OBJECT (demux,
|
||||||
"Non-flushing non-instant-rate seeks are not possible");
|
"Non-flushing non-instant-rate seeks are not possible");
|
||||||
|
goto unlock_return;
|
||||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
|
||||||
|
|
||||||
GST_API_UNLOCK (demux);
|
|
||||||
gst_event_unref (event);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gst_adaptive_demux_is_live (demux)) {
|
if (gst_adaptive_demux_is_live (demux)) {
|
||||||
|
@ -2166,11 +2149,8 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
||||||
|
|
||||||
if (!gst_adaptive_demux_get_live_seek_range (demux, &range_start,
|
if (!gst_adaptive_demux_get_live_seek_range (demux, &range_start,
|
||||||
&range_stop)) {
|
&range_stop)) {
|
||||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
|
||||||
GST_API_UNLOCK (demux);
|
|
||||||
gst_event_unref (event);
|
|
||||||
GST_WARNING_OBJECT (demux, "Failure getting the live seek ranges");
|
GST_WARNING_OBJECT (demux, "Failure getting the live seek ranges");
|
||||||
return FALSE;
|
goto unlock_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (demux,
|
GST_DEBUG_OBJECT (demux,
|
||||||
|
@ -2232,12 +2212,8 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the seek position is still outside of the seekable range, refuse the seek */
|
/* If the seek position is still outside of the seekable range, refuse the seek */
|
||||||
if (!start_valid || !stop_valid) {
|
if (!start_valid || !stop_valid)
|
||||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
goto unlock_return;
|
||||||
GST_API_UNLOCK (demux);
|
|
||||||
gst_event_unref (event);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Re-create seek event with changed/updated values */
|
/* Re-create seek event with changed/updated values */
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
@ -2335,17 +2311,8 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
||||||
GST_DEBUG_OBJECT (demux,
|
GST_DEBUG_OBJECT (demux,
|
||||||
"Seek on stream %" GST_PTR_FORMAT " failed with flow return %s",
|
"Seek on stream %" GST_PTR_FORMAT " failed with flow return %s",
|
||||||
stream, gst_flow_get_name (flow_ret));
|
stream, gst_flow_get_name (flow_ret));
|
||||||
|
|
||||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
|
||||||
GST_ADAPTIVE_DEMUX_SEGMENT_UNLOCK (demux);
|
GST_ADAPTIVE_DEMUX_SEGMENT_UNLOCK (demux);
|
||||||
|
goto unlock_return;
|
||||||
|
|
||||||
GST_API_UNLOCK (demux);
|
|
||||||
|
|
||||||
gst_event_unref (event);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/* replace event with a new one without snapping to seek on all streams */
|
/* replace event with a new one without snapping to seek on all streams */
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
|
@ -2411,6 +2378,7 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
||||||
gst_adaptive_demux_set_streams_can_download_fragments (demux, TRUE);
|
gst_adaptive_demux_set_streams_can_download_fragments (demux, TRUE);
|
||||||
gst_adaptive_demux_start_tasks (demux);
|
gst_adaptive_demux_start_tasks (demux);
|
||||||
|
|
||||||
|
unlock_return:
|
||||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
||||||
GST_API_UNLOCK (demux);
|
GST_API_UNLOCK (demux);
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
|
|
Loading…
Reference in a new issue