diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2013-09-18 17:51:26 +0200 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2013-09-28 13:31:13 +0200 |
commit | 93ec45a6dfaa9fb0047742fb85314c4946b35070 (patch) | |
tree | 2288519f4b250887528eb6d63caa8cb79b234066 | |
parent | a1cc9ca4de84d3230a4db875db8ef0983372d57d (diff) | |
download | gstreamer-plugins-bad-93ec45a6dfaa9fb0047742fb85314c4946b35070.tar.gz |
liveadder: round when calculation length from duration
liveadder sometimes calculates the offsets incorrectly before adding. The
resulting errors can easily be heard when mixing silence with a sine.
I'm not sure what the exact conditions are to trigger this, but it definitively
happens when the buffers of two streams have a different duration and buffer
length and duration don't match exactly for one stream because of rounding
errors (e.g. duration=0:00:00.021333333)
I have to admit, I got lost in the math somewhere but it seems that not
rounding in gst_live_adder_length_from_duration() causes 1 sample overlaps in
consecutive buffers from the same stream.
When using gst_util_uint64_scale_int_round() instead of just truncating the
sine sound correctly again.
https://bugzilla.gnome.org/show_bug.cgi?id=708345
-rw-r--r-- | gst/liveadder/liveadder.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gst/liveadder/liveadder.c b/gst/liveadder/liveadder.c index 0500e4bbd..f41de3fe1 100644 --- a/gst/liveadder/liveadder.c +++ b/gst/liveadder/liveadder.c @@ -918,7 +918,8 @@ gst_live_adder_length_from_duration (GstLiveAdder * adder, GstClockTime duration) { guint64 ret = GST_AUDIO_INFO_BPF (&adder->info) * - (duration * GST_AUDIO_INFO_RATE (&adder->info) / GST_SECOND); + gst_util_uint64_scale_int_round (duration, + GST_AUDIO_INFO_RATE (&adder->info), GST_SECOND); return (guint) ret; } |