Commit 27ee99e9 authored by Alicia Boya García's avatar Alicia Boya García

matroskademux: Guard read state transitions with locks

This patch adds locks to all pieces of code that were changing the read
state of matroskademux and were not already locking it.

This is necessary for seek event deferring to work without races.
parent e301606e
Pipeline #12355 failed with stages
in 31 seconds
......@@ -2440,10 +2440,10 @@ gst_matroska_demux_search_pos (GstMatroskaDemux * demux, GstClockTime time)
current_cluster_time = demux->cluster_time;
current_offset = demux->common.offset;
GST_OBJECT_LOCK (demux);
demux->common.state = GST_MATROSKA_READ_STATE_SCANNING;
/* estimate using start and last known cluster */
GST_OBJECT_LOCK (demux);
apos = demux->first_cluster_offset;
atime = demux->stream_start_time;
opos = demux->last_cluster_offset;
......@@ -2643,7 +2643,9 @@ exit:
demux->cluster_offset = current_cluster_offset;
demux->cluster_time = current_cluster_time;
demux->common.offset = current_offset;
GST_OBJECT_LOCK (demux);
demux->common.state = current_state;
GST_OBJECT_UNLOCK (demux);
return entry;
}
......@@ -5211,7 +5213,9 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id,
ret = gst_matroska_read_common_parse_header (&demux->common, &ebml);
if (ret != GST_FLOW_OK)
goto parse_failed;
GST_OBJECT_LOCK (demux);
demux->common.state = GST_MATROSKA_READ_STATE_SEGMENT;
GST_OBJECT_UNLOCK (demux);
gst_matroska_demux_check_seekability (demux);
break;
default:
......@@ -5233,7 +5237,9 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id,
if (length == 0)
length = G_MAXUINT64;
demux->common.ebml_segment_length = length;
GST_OBJECT_LOCK (demux);
demux->common.state = GST_MATROSKA_READ_STATE_HEADER;
GST_OBJECT_UNLOCK (demux);
break;
default:
GST_WARNING_OBJECT (demux,
......@@ -5258,7 +5264,9 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id,
if (demux->common.start_resync_offset != -1) {
GST_LOG_OBJECT (demux, "Resync done, new cluster found!");
demux->common.start_resync_offset = -1;
GST_OBJECT_LOCK (demux);
demux->common.state = demux->common.state_to_restore;
GST_OBJECT_UNLOCK (demux);
}
}
/* fall-through */
......@@ -5268,7 +5276,9 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id,
switch (id) {
case GST_EBML_ID_HEADER:
GST_READ_CHECK (gst_matroska_demux_flush (demux, read));
GST_OBJECT_LOCK (demux);
demux->common.state = GST_MATROSKA_READ_STATE_SEGMENT;
GST_OBJECT_UNLOCK (demux);
gst_matroska_demux_check_seekability (demux);
break;
case GST_MATROSKA_ID_SEGMENTINFO:
......@@ -5302,7 +5312,9 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id,
}
}
if (demux->common.state == GST_MATROSKA_READ_STATE_HEADER) {
GST_OBJECT_LOCK (demux);
demux->common.state = GST_MATROSKA_READ_STATE_DATA;
GST_OBJECT_UNLOCK (demux);
demux->first_cluster_offset = demux->common.offset;
if (!demux->streaming &&
......@@ -5802,7 +5814,9 @@ next:
"parse error, looking for next cluster, actual offset %"
G_GUINT64_FORMAT ", start resync offset %" G_GUINT64_FORMAT,
demux->common.offset, demux->common.start_resync_offset);
GST_OBJECT_LOCK (demux);
demux->common.state = GST_MATROSKA_READ_STATE_SCANNING;
GST_OBJECT_UNLOCK (demux);
ret = GST_FLOW_OK;
} else {
GST_WARNING_OBJECT (demux,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment