audiotestsrc: Fix segment boundary checking for reverse playback

This commit is contained in:
Sebastian Dröge 2016-09-17 12:42:46 +02:00
parent cf18fae9de
commit 031f256584

View file

@ -1123,11 +1123,16 @@ gst_audio_test_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment)
src->next_sample = next_sample; src->next_sample = next_sample;
if (GST_CLOCK_TIME_IS_VALID (segment->stop)) { if (segment->rate > 0 && GST_CLOCK_TIME_IS_VALID (segment->stop)) {
time = segment->stop; time = segment->stop;
src->sample_stop = src->sample_stop =
gst_util_uint64_scale_round (time, samplerate, GST_SECOND); gst_util_uint64_scale_round (time, samplerate, GST_SECOND);
src->check_seek_stop = TRUE; src->check_seek_stop = TRUE;
} else if (segment->rate < 0) {
time = segment->start;
src->sample_stop =
gst_util_uint64_scale_round (time, samplerate, GST_SECOND);
src->check_seek_stop = TRUE;
} else { } else {
src->check_seek_stop = FALSE; src->check_seek_stop = FALSE;
} }
@ -1202,7 +1207,7 @@ gst_audio_test_src_fill (GstBaseSrc * basesrc, guint64 offset,
} }
/* check for eos */ /* check for eos */
if (src->check_seek_stop && if (src->check_seek_stop && !src->reverse &&
(src->sample_stop > src->next_sample) && (src->sample_stop > src->next_sample) &&
(src->sample_stop < src->next_sample + samples) (src->sample_stop < src->next_sample + samples)
) { ) {
@ -1210,6 +1215,13 @@ gst_audio_test_src_fill (GstBaseSrc * basesrc, guint64 offset,
src->generate_samples_per_buffer = src->sample_stop - src->next_sample; src->generate_samples_per_buffer = src->sample_stop - src->next_sample;
next_sample = src->sample_stop; next_sample = src->sample_stop;
src->eos_reached = TRUE; src->eos_reached = TRUE;
} else if (src->check_seek_stop && src->reverse &&
(src->sample_stop > src->next_sample)
) {
/* calculate only partial buffer */
src->generate_samples_per_buffer = src->sample_stop - src->next_sample;
next_sample = src->sample_stop;
src->eos_reached = TRUE;
} else { } else {
/* calculate full buffer */ /* calculate full buffer */
src->generate_samples_per_buffer = samples; src->generate_samples_per_buffer = samples;