From f68c95ebaae922f7af136fff471bcd70461e5e77 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 29 Mar 2013 16:44:17 +0100 Subject: [PATCH] audiotestssrc: truncate the seek pos to the sample and round the time Before it was done the other way around and that can trigger the assert that already is in place. This also makes more sense; when seeking to time x, we want then sample that is <= that pos. --- gst/audiotestsrc/gstaudiotestsrc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c index 872b8da..0ca90cd 100644 --- a/gst/audiotestsrc/gstaudiotestsrc.c +++ b/gst/audiotestsrc/gstaudiotestsrc.c @@ -1049,6 +1049,7 @@ gst_audio_test_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment) GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (basesrc); GstClockTime time; gint samplerate, bpf; + gint64 next_sample; GST_DEBUG_OBJECT (src, "seeking %" GST_SEGMENT_FORMAT, segment); @@ -1058,21 +1059,23 @@ gst_audio_test_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment) samplerate = GST_AUDIO_INFO_RATE (&src->info); bpf = GST_AUDIO_INFO_BPF (&src->info); - /* now move to the time indicated */ - src->next_sample = gst_util_uint64_scale_round (time, samplerate, GST_SECOND); - src->next_byte = src->next_sample * bpf; + /* now move to the time indicated, don't see to the sample *after* the time */ + next_sample = gst_util_uint64_scale_int (time, samplerate, GST_SECOND); + src->next_byte = next_sample * bpf; if (samplerate == 0) src->next_time = 0; else src->next_time = - gst_util_uint64_scale_int (src->next_sample, GST_SECOND, samplerate); + gst_util_uint64_scale_round (next_sample, GST_SECOND, samplerate); GST_DEBUG_OBJECT (src, "seeking next_sample=%" G_GINT64_FORMAT - " next_time=%" GST_TIME_FORMAT, src->next_sample, + " next_time=%" GST_TIME_FORMAT, next_sample, GST_TIME_ARGS (src->next_time)); g_assert (src->next_time <= time); + src->next_sample = next_sample; + if (!src->reverse) { if (GST_CLOCK_TIME_IS_VALID (segment->start)) { segment->time = segment->start; -- 2.7.4