avwait: Don't reset time tracking when receiving the same segment again

This causes avwait to go back into "dropping" mode until audio and video
are synced again, which is unnecessary when the segment didn't actually
change.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2121>
This commit is contained in:
Sebastian Dröge 2021-03-29 12:15:18 +03:00 committed by GStreamer Marge Bot
parent 791f1da7b8
commit 5bcfb2dda0

View file

@ -616,16 +616,21 @@ gst_avwait_vsink_event (GstPad * pad, GstObject * parent, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEGMENT:{ case GST_EVENT_SEGMENT:{
const GstSegment *segment;
gboolean send_message = FALSE; gboolean send_message = FALSE;
gboolean segment_changed;
g_mutex_lock (&self->mutex); g_mutex_lock (&self->mutex);
gst_event_copy_segment (event, &self->vsegment); gst_event_parse_segment (event, &segment);
segment_changed = !gst_segment_is_equal (segment, &self->vsegment);
self->vsegment = *segment;
if (self->vsegment.format != GST_FORMAT_TIME) { if (self->vsegment.format != GST_FORMAT_TIME) {
GST_ERROR_OBJECT (self, "Invalid segment format"); GST_ERROR_OBJECT (self, "Invalid segment format");
g_mutex_unlock (&self->mutex); g_mutex_unlock (&self->mutex);
gst_event_unref (event); gst_event_unref (event);
return FALSE; return FALSE;
} }
if (segment_changed) {
GST_DEBUG_OBJECT (self, "First time reset in video segment"); GST_DEBUG_OBJECT (self, "First time reset in video segment");
self->running_time_to_wait_for = GST_CLOCK_TIME_NONE; self->running_time_to_wait_for = GST_CLOCK_TIME_NONE;
self->running_time_to_end_at = GST_CLOCK_TIME_NONE; self->running_time_to_end_at = GST_CLOCK_TIME_NONE;
@ -636,6 +641,7 @@ gst_avwait_vsink_event (GstPad * pad, GstObject * parent, GstEvent * event)
send_message = TRUE; send_message = TRUE;
} }
self->vsegment.position = GST_CLOCK_TIME_NONE; self->vsegment.position = GST_CLOCK_TIME_NONE;
}
g_mutex_unlock (&self->mutex); g_mutex_unlock (&self->mutex);
if (send_message) if (send_message)
@ -750,18 +756,28 @@ gst_avwait_asink_event (GstPad * pad, GstObject * parent, GstEvent * event)
GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event)); GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEGMENT: case GST_EVENT_SEGMENT:{
const GstSegment *segment;
gboolean segment_changed;
g_mutex_lock (&self->mutex); g_mutex_lock (&self->mutex);
gst_event_copy_segment (event, &self->asegment); gst_event_parse_segment (event, &segment);
segment_changed = !gst_segment_is_equal (segment, &self->asegment);
self->asegment = *segment;
if (self->asegment.format != GST_FORMAT_TIME) { if (self->asegment.format != GST_FORMAT_TIME) {
GST_ERROR_OBJECT (self, "Invalid segment format"); GST_ERROR_OBJECT (self, "Invalid segment format");
g_mutex_unlock (&self->mutex); g_mutex_unlock (&self->mutex);
gst_event_unref (event); gst_event_unref (event);
return FALSE; return FALSE;
} }
if (segment_changed) {
self->asegment.position = GST_CLOCK_TIME_NONE; self->asegment.position = GST_CLOCK_TIME_NONE;
}
g_mutex_unlock (&self->mutex); g_mutex_unlock (&self->mutex);
break; break;
}
case GST_EVENT_FLUSH_START: case GST_EVENT_FLUSH_START:
g_mutex_lock (&self->mutex); g_mutex_lock (&self->mutex);
self->audio_flush_flag = TRUE; self->audio_flush_flag = TRUE;