GNOME Bugzilla – Bug 607381
GST_FRAMES_TO_CLOCK_TIME() GST_CLOCK_TIME_TO_FRAMES() should round result
Last modified: 2010-01-19 08:26:55 UTC
The macros GST_FRAMES_TO_CLOCK_TIME() and GST_CLOCK_TIME_TO_FRAMES() use gst_util_uint64_scale() to convert a sample offset to a clock time and vice versa. This function truncates its results. gst_util_uint64_scale_round() should be used instead to round the answer to the nearest integer result. This prevents a clock drift when sample indexes are converted to clock times and back to sample indexes, etc., repeatedly when working with data streams whose sample periods are not exactly an integer number of nanoseconds (e.g., power-of-2 sample rates like 16384 Hz). For example, GST_CLOCK_TIME_TO_FRAMES(GST_FRAMES_TO_CLOCK_TIME(n,16384),16384) returns n-1 for most n. Changing these macros to the rounding versions does not break the unit tests for the elements that use them already.
commit 6dfc0270eccc394fc46f4c83127fc7b600a991cd Author: Sebastian Dröge <sebastian.droege@collabora.co.uk> Date: Tue Jan 19 09:25:35 2010 +0100 audio: Use rounding scaling functions for GST_CLOCK_TIME_TO_FRAMES and _FRAM Fixes bug #607381.