GNOME Bugzilla – Bug 676884
audiotestsrc: segment one sample too short due to rounding errors
Last modified: 2013-03-24 20:55:21 UTC
Created attachment 215047 [details] Source for a program that writes a wav file of given length The resulting segment length is incorrect when doing sample (GST_FORMAT_DEFAULT) seek on audiotestsrc. The reason for this seems to be that the sample index is first converted to nanoseconds (GST_FORMAT_TIME) and then back to samples. Due to rounding errors this often produce one sample less than intended. I suggest using gst_util_uint64_scale_int_round instead of gst_util_uint64_scale_int in gstaudiotestsrc.c when converting from time to samples. I've attached a test program that should produce a sine tone in /tmp/segment.wav with the length as given by the command line argument. In reality the resulting file is often one sample short.
Sorry for overlooking thsi report. Could you try again with 1.0? Ideally change your example into a unit test for gst-plugins-base/tests/check/elements/audiotestsrc.c Your proposed fix sounds sensible, please try it and then attach a patch here containing the tests and fix. Thanks!
commit f18d2a5a9a27de45539089b2f3a38bddf74cd784 Author: Simon Berg <ksb@kth.se> Date: Sun Mar 24 20:44:58 2013 +0000 audiotestsrc: fix rounding errors that might cause segments to be one sample too short https://bugzilla.gnome.org/show_bug.cgi?id=676884 commit d8b42e993b6f836f7c11baacbf6ee5dea84b67b0 Author: Simon Berg <ksb@kth.se> Date: Sun Mar 24 20:41:44 2013 +0000 audiotestsrc: fix buffer size of last buffer The last buffer before EOS may be smaller than the maximum size. The current code doesn't adjust for this, it only sets the duration and offsets. https://bugzilla.gnome.org/show_bug.cgi?id=696411