From 7927f49ca0a70868244353a083ccd4601580dbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 19 Jan 2016 14:57:03 +0200 Subject: [PATCH] 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. --- gst/wavparse/gstwavparse.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c index 5aa86cb6d0..138ec1646f 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -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 {