From 5a73374f2c30e817440c3a71f0fdac9f1d6b9704 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 22 Aug 2011 10:40:45 +0100 Subject: [PATCH] flacdec: fix off by one between granpos and last_stop --- ext/flac/gstflacdec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index 1e2ef5e..a12fd24 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -978,7 +978,9 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame, if (flacdec->cur_granulepos != GST_BUFFER_OFFSET_NONE) { /* this should be fine since it should be one flac frame per ogg packet */ - flacdec->segment.last_stop = flacdec->cur_granulepos - samples; + /* note the + 1, as the granpos is the presentation time of the last sample, + whereas the last stop represents the end time of that sample */ + flacdec->segment.last_stop = flacdec->cur_granulepos - samples + 1; GST_LOG_OBJECT (flacdec, "granulepos = %" G_GINT64_FORMAT ", samples = %u", flacdec->cur_granulepos, samples); } -- 2.7.4