wavparse: Don't play anything after the end of the data chunk even when seeking

Especially in push mode we would completely ignore the size of the data chunk
when not stop position is given for the seek. Instead make sure that the end
offset is at most the end of the data chunk if known.

Without this we would output anything after the data chunk, possibly causing
loud noises if the media file is followed by an INFO chunk or an ID3 tag.
This commit is contained in:
Sebastian Dröge 2016-01-19 14:57:03 +02:00
parent 322bdf5136
commit 7927f49ca0

View file

@ -541,6 +541,9 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
if (gst_pad_peer_query_duration (wav->sinkpad, bformat, &upstream_size))
wav->end_offset = MIN (wav->end_offset, upstream_size);
if (wav->datasize > 0 && wav->end_offset > wav->datastart + wav->datasize)
wav->end_offset = wav->datastart + wav->datasize;
/* this is the range of bytes we will use for playback */
wav->offset = MIN (wav->offset, wav->end_offset);
wav->dataleft = wav->end_offset - wav->offset;
@ -2420,6 +2423,11 @@ gst_wavparse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
/* and set up streaming thread for next one */
wav->offset = offset;
wav->end_offset = end_offset;
if (wav->datasize > 0 && (wav->end_offset == -1
|| wav->end_offset > wav->datastart + wav->datasize))
wav->end_offset = wav->datastart + wav->datasize;
if (wav->end_offset != -1) {
wav->dataleft = wav->end_offset - wav->offset;
} else {