From a76af918d0d2a4c391e84be525efb7834c75ad26 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 6 Jan 2010 14:06:14 +0100 Subject: [PATCH] flacdec: really use upstream timestamp if there is one See/fixes #603471. --- ext/flac/gstflacdec.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index a11d23f44c..2759b0dff0 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -39,6 +39,7 @@ */ /* TODO: add seeking when operating chain-based with unframed input */ +/* FIXME: demote/remove granulepos handling and make more time-centric */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1301,8 +1302,19 @@ gst_flac_dec_chain (GstPad * pad, GstBuffer * buf) GST_BUFFER_SIZE (buf), &unused); /* oggdemux will set granulepos in OFFSET_END instead of timestamp */ - if (got_audio_frame && !GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { - dec->cur_granulepos = GST_BUFFER_OFFSET_END (buf); + if (G_LIKELY (got_audio_frame)) { + /* old oggdemux for now */ + if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { + dec->cur_granulepos = GST_BUFFER_OFFSET_END (buf); + } else { + GstFormat dformat = GST_FORMAT_DEFAULT; + + /* upstream (e.g. demuxer) presents us time, + * convert to default samples */ + gst_flac_dec_convert_src (dec->srcpad, GST_FORMAT_TIME, + GST_BUFFER_TIMESTAMP (buf), &dformat, &dec->segment.last_stop); + dec->cur_granulepos = GST_BUFFER_OFFSET_NONE; + } } } else { dec->cur_granulepos = GST_BUFFER_OFFSET_NONE;