flacdec: fix off by one between granpos and last_stop
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 22 Aug 2011 09:40:45 +0000 (10:40 +0100)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 7 Nov 2011 12:38:10 +0000 (12:38 +0000)
ext/flac/gstflacdec.c

index 1e2ef5e..a12fd24 100644 (file)
@@ -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);
   }