From 490e4089913c160e654e93ca64cba3aa3275d68f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 23 Oct 2012 14:32:24 +0200 Subject: [PATCH] scaletempo: Fix timestamp tracking --- gst/audiofx/gstscaletempo.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gst/audiofx/gstscaletempo.c b/gst/audiofx/gstscaletempo.c index 8312335..f2a5240 100644 --- a/gst/audiofx/gstscaletempo.c +++ b/gst/audiofx/gstscaletempo.c @@ -452,6 +452,7 @@ gst_scaletempo_transform (GstBaseTransform * trans, gint8 *pout; guint offset_in, bytes_out; GstMapInfo omap; + GstClockTime timestamp; gst_buffer_map (outbuf, &omap, GST_MAP_WRITE); pout = (gint8 *) omap.data; @@ -487,11 +488,17 @@ gst_scaletempo_transform (GstBaseTransform * trans, gst_buffer_unmap (outbuf, &omap); + timestamp = GST_BUFFER_TIMESTAMP (inbuf) - p->segment_start; + if (timestamp < p->latency) + timestamp = 0; + else + timestamp -= p->latency; + GST_BUFFER_TIMESTAMP (outbuf) = timestamp / p->scale + p->segment_start; + GST_BUFFER_DURATION (outbuf) = + gst_util_uint64_scale (bytes_out, GST_SECOND, + p->bytes_per_frame * p->sample_rate); gst_buffer_set_size (outbuf, bytes_out); - GST_BUFFER_TIMESTAMP (outbuf) = - (GST_BUFFER_TIMESTAMP (outbuf) - p->segment_start) / p->scale + - p->segment_start; - //GST_BUFFER_DURATION (outbuf) = bytes_out * GST_SECOND / (p->bytes_per_frame * p->sample_rate); + return GST_FLOW_OK; } -- 2.7.4