mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
splitmuxsrc: Protect total_duration state variable with the object lock.
Prevent deadlocks from downstream querying duration from the streaming thread.
This commit is contained in:
parent
d7794a6f61
commit
94e113c6c6
1 changed files with 14 additions and 7 deletions
|
@ -606,6 +606,7 @@ gst_splitmux_src_start (GstSplitMuxSrc * splitmux)
|
||||||
gchar **files;
|
gchar **files;
|
||||||
GstClockTime next_offset = 0;
|
GstClockTime next_offset = 0;
|
||||||
guint i;
|
guint i;
|
||||||
|
GstClockTime total_duration = 0;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (splitmux, "Starting");
|
GST_DEBUG_OBJECT (splitmux, "Starting");
|
||||||
|
|
||||||
|
@ -649,13 +650,19 @@ gst_splitmux_src_start (GstSplitMuxSrc * splitmux)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extend our total duration to cover this part */
|
/* Extend our total duration to cover this part */
|
||||||
splitmux->total_duration =
|
total_duration =
|
||||||
next_offset +
|
next_offset +
|
||||||
gst_splitmux_part_reader_get_duration (splitmux->parts[i]);
|
gst_splitmux_part_reader_get_duration (splitmux->parts[i]);
|
||||||
splitmux->play_segment.duration = splitmux->total_duration;
|
splitmux->play_segment.duration = total_duration;
|
||||||
|
|
||||||
next_offset = gst_splitmux_part_reader_get_end_offset (splitmux->parts[i]);
|
next_offset = gst_splitmux_part_reader_get_end_offset (splitmux->parts[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update total_duration state variable */
|
||||||
|
GST_OBJECT_LOCK (splitmux);
|
||||||
|
splitmux->total_duration = total_duration;
|
||||||
|
GST_OBJECT_UNLOCK (splitmux);
|
||||||
|
|
||||||
/* Store how many parts we actually created */
|
/* Store how many parts we actually created */
|
||||||
splitmux->num_parts = i;
|
splitmux->num_parts = i;
|
||||||
|
|
||||||
|
@ -665,7 +672,7 @@ gst_splitmux_src_start (GstSplitMuxSrc * splitmux)
|
||||||
/* All done preparing, activate the first part */
|
/* All done preparing, activate the first part */
|
||||||
GST_INFO_OBJECT (splitmux,
|
GST_INFO_OBJECT (splitmux,
|
||||||
"All parts prepared. Total duration %" GST_TIME_FORMAT
|
"All parts prepared. Total duration %" GST_TIME_FORMAT
|
||||||
" Activating first part", GST_TIME_ARGS (splitmux->total_duration));
|
" Activating first part", GST_TIME_ARGS (total_duration));
|
||||||
gst_splitmux_src_activate_part (splitmux, 0);
|
gst_splitmux_src_activate_part (splitmux, 0);
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
@ -1094,13 +1101,13 @@ splitmux_src_pad_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
if (fmt != GST_FORMAT_TIME)
|
if (fmt != GST_FORMAT_TIME)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SPLITMUX_SRC_LOCK (splitmux);
|
GST_OBJECT_LOCK (splitmux);
|
||||||
if (splitmux->total_duration > 0) {
|
if (splitmux->total_duration > 0) {
|
||||||
gst_query_set_duration (query, GST_FORMAT_TIME,
|
gst_query_set_duration (query, GST_FORMAT_TIME,
|
||||||
splitmux->total_duration);
|
splitmux->total_duration);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
SPLITMUX_SRC_UNLOCK (splitmux);
|
GST_OBJECT_UNLOCK (splitmux);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_QUERY_SEEKING:{
|
case GST_QUERY_SEEKING:{
|
||||||
|
@ -1110,11 +1117,11 @@ splitmux_src_pad_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
if (format != GST_FORMAT_TIME)
|
if (format != GST_FORMAT_TIME)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SPLITMUX_SRC_LOCK (splitmux);
|
GST_OBJECT_LOCK (splitmux);
|
||||||
gst_query_set_seeking (query, GST_FORMAT_TIME, TRUE, 0,
|
gst_query_set_seeking (query, GST_FORMAT_TIME, TRUE, 0,
|
||||||
splitmux->total_duration);
|
splitmux->total_duration);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
SPLITMUX_SRC_UNLOCK (splitmux);
|
GST_OBJECT_UNLOCK (splitmux);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue