From 8009fcf547b7caebe407fe272293c733d488ccb4 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 1 Apr 2009 01:15:31 +0200 Subject: add pending_samples so that we only update segment's last stop after really sending the samples --- ext/flac/gstflacdec.c | 9 ++++++++- ext/flac/gstflacdec.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'ext/flac') diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index b533d0b0..ff3da8b7 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -931,6 +931,8 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame, GST_TIME_ARGS (GST_BUFFER_DURATION (flacdec->pending))); gst_pad_push (flacdec->srcpad, flacdec->pending); flacdec->pending = NULL; + flacdec->segment.last_stop += flacdec->pending_samples; + flacdec->pending_samples = 0; } ret = gst_pad_alloc_buffer_and_set_caps (flacdec->srcpad, @@ -1003,11 +1005,13 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame, } ret = gst_pad_push (flacdec->srcpad, outbuf); GST_DEBUG_OBJECT (flacdec, "returned %s", gst_flow_get_name (ret)); + flacdec->segment.last_stop += samples; } else { GST_DEBUG_OBJECT (flacdec, "not pushing %d samples at offset %" G_GINT64_FORMAT " (in seek)", samples, GST_BUFFER_OFFSET (outbuf)); gst_buffer_replace (&flacdec->pending, outbuf); + flacdec->pending_samples = samples; ret = GST_FLOW_OK; } @@ -1018,7 +1022,6 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame, done: - flacdec->segment.last_stop += samples; /* we act on the flow return value later in the loop function, as we don't * want to mess up the internal decoder state by returning ABORT when the @@ -1761,6 +1764,10 @@ gst_flac_dec_handle_seek_event (GstFlacDec * flacdec, GstEvent * event) flacdec->seeking = FALSE; + GST_DEBUG_OBJECT (flacdec, "performed seek to sample %" G_GINT64_FORMAT, + flacdec->segment.last_stop); + + if (!seek_ok) { GST_WARNING_OBJECT (flacdec, "seek failed"); /* seek failed, restore the segment and start streaming again with diff --git a/ext/flac/gstflacdec.h b/ext/flac/gstflacdec.h index a3be8fe6..a9daf3e9 100644 --- a/ext/flac/gstflacdec.h +++ b/ext/flac/gstflacdec.h @@ -69,6 +69,7 @@ struct _GstFlacDec { gboolean running; gboolean discont; GstBuffer *pending; /* pending buffer, produced in seek */ + guint pending_samples; GstEvent *close_segment; GstEvent *start_segment; GstTagList *tags; -- cgit