Problems with segment seek on audiotestsrc

Simon Berg ksb at fluffware.se
Mon May 21 10:30:15 PDT 2012


On Sun, 2012-05-20 at 21:52 +0200, Stefan Sauer wrote:
> On 05/13/2012 02:32 PM, Simon Berg wrote:
> > I'm using audiotestsrc together with a segment seek to produce silence
> > for a fixed number of samples. The seek uses GST_FORMAT_DEFAULT to get
> > the desired number of samples. 
> > The problem is that I sometimes get one samples less than expected.
> > As far as I'm able to tell this is because audiotestsrc use
> > GST_FORMAT_TIME internally, so the sample number from the event is first
> > converted to ns and than back to samples. The result is sometimes one
> > sample less due to rounding errors.
> >
> > I think the problem can be solved by using
> > gst_util_uint64_scale_int_round instead of gst_util_uint64_scale_int
> > when converting from ns to samples.
> >
> > I'm currently using 0.10.36, but the conversion seems to be done the
> > same way in current git.
> >
> > Is there a workaround for this? Is there an alternative element to
> > generate silence?
> >
> > simon
> >
> >
> Could you please file a bug for this?
I will.

>  One workaround would be to do the
> time conversion on your side and use GST_FORMAT_TIME when seeking.
Unfortunately that doesn't seem to work. I converted the sample index to
GstClockTime and added 1ns to make sure it would convert back to the
correct number of sample. The problem was that the last buffer returned
to GstBaseSrc from the create method of the subclass had a timestamp
that was smaller than the segment end so it was called an extra time
which resulted in a full buffer. 
How is a subclass of GstBaseSrc supposed to behave when the requested
length doesn't match a whole number of samples (or frames)?
Especially if the time is just slightly passed a full sample.

There are probably even more problems when mixing times and samples,
but I have to think that through a bit more.

simon





More information about the gstreamer-devel mailing list