From a3513d6e977853a6f4d8a6062152f2b664ab8f34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 31 Aug 2015 15:35:11 +0300 Subject: [PATCH] event: Make sure that timestamp + diff in QoS events is never smaller than 0 When a running-time-offset is stored in the event, it could become smaller than 0 although the event is otherwise correct. This can happen when pad offsets are used. To prevent this, we set the timestamp to -diff, so that in the end the sum of both is exactly 0. https://bugzilla.gnome.org/show_bug.cgi?id=754356 --- gst/gstevent.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gst/gstevent.c b/gst/gstevent.c index 421682c..baeb0f4 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -1057,6 +1057,9 @@ gst_event_parse_qos (GstEvent * event, GstQOSType * type, GST_QUARK (DIFF))); if (timestamp) { gint64 offset = gst_event_get_running_time_offset (event); + GstClockTimeDiff diff_ = + g_value_get_int64 (gst_structure_id_get_value (structure, + GST_QUARK (DIFF))); *timestamp = g_value_get_uint64 (gst_structure_id_get_value (structure, @@ -1066,6 +1069,11 @@ gst_event_parse_qos (GstEvent * event, GstQOSType * type, *timestamp += offset; else *timestamp = 0; + + /* Make sure that timestamp + diff is always >= 0. Because + * of the running time offset this might not be true */ + if (diff_ < 0 && *timestamp < -diff_) + *timestamp = (GstClockTime) - diff_; } } -- 2.7.4