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
This commit is contained in:
Sebastian Dröge 2015-08-31 15:35:11 +03:00
parent 697093c7d4
commit a3513d6e97

View file

@ -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_;
}
}