After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 676884 - audiotestsrc: segment one sample too short due to rounding errors
audiotestsrc: segment one sample too short due to rounding errors
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
0.10.36
Other Linux
: Normal normal
: 1.1.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-05-26 14:39 UTC by ksb
Modified: 2013-03-24 20:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Source for a program that writes a wav file of given length (4.97 KB, text/x-csrc)
2012-05-26 14:39 UTC, ksb
Details

Description ksb 2012-05-26 14:39:56 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.
Comment 1 Stefan Sauer (gstreamer, gtkdoc dev) 2013-03-18 16:11:59 UTC
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!
Comment 2 Tim-Philipp Müller 2013-03-24 20:55:21 UTC
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