concat: fix locking in SEGMENT event handler

concat->current_start_offset needs the lock taken for safe access,
as it can be accessed from outside of the streaming thread, eg
in release_pad.

An early break is also added for an error case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/818>
This commit is contained in:
Mathieu Duponchelle 2021-05-11 19:02:28 +02:00 committed by GStreamer Marge Bot
parent 24f0370c2d
commit d7272b3247

View file

@ -558,7 +558,6 @@ gst_concat_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
self->format = spad->segment.format;
GST_DEBUG_OBJECT (self, "Operating in %s format",
gst_format_get_name (self->format));
g_mutex_unlock (&self->lock);
} else if (self->format != spad->segment.format) {
g_mutex_unlock (&self->lock);
GST_ELEMENT_ERROR (self, CORE, FAILED, (NULL),
@ -566,16 +565,19 @@ gst_concat_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
gst_format_get_name (self->format),
gst_format_get_name (spad->segment.format)));
ret = FALSE;
} else {
g_mutex_unlock (&self->lock);
break;
}
g_mutex_unlock (&self->lock);
if (!gst_concat_pad_wait (spad, self)) {
ret = FALSE;
} else {
GstSegment segment = spad->segment;
GstEvent *topush;
g_mutex_lock (&self->lock);
if (adjust_base) {
/* We know no duration */
segment.duration = -1;
@ -609,6 +611,8 @@ gst_concat_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
topush = gst_event_new_segment (&segment);
gst_event_set_seqnum (topush, gst_event_get_seqnum (event));
g_mutex_unlock (&self->lock);
gst_pad_push_event (self->srcpad, topush);
}
break;