add pending_samples so that we only update segment's last stop after really sending the samples

This commit is contained in:
Thomas Vander Stichele 2009-04-01 01:15:31 +02:00 committed by Thomas Vander Stichele
parent 5f802dad4e
commit 8009fcf547
2 changed files with 9 additions and 1 deletions

View file

@ -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

View file

@ -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;