summaryrefslogtreecommitdiff
path: root/gst/audiotestsrc
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2013-03-29 16:44:17 +0100
committerStefan Sauer <ensonic@users.sf.net>2013-03-29 16:46:14 +0100
commitf68c95ebaae922f7af136fff471bcd70461e5e77 (patch)
tree730a1d199329596c92a4776e4c5f1e2910bad72c /gst/audiotestsrc
parent3d1322f08ec21300978c10b67e5ebe08b3f0c46b (diff)
downloadgstreamer-plugins-base-f68c95ebaae922f7af136fff471bcd70461e5e77.tar.gz
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.
Diffstat (limited to 'gst/audiotestsrc')
-rw-r--r--gst/audiotestsrc/gstaudiotestsrc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c
index 872b8daf2..0ca90cdab 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;