diff options
-rw-r--r-- | gst/audioresample/gstaudioresample.c | 12 | ||||
-rw-r--r-- | gst/audioresample/gstaudioresample.h | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c index cbbfe81a..02537075 100644 --- a/gst/audioresample/gstaudioresample.c +++ b/gst/audioresample/gstaudioresample.c @@ -395,14 +395,20 @@ static GstFlowReturn GST_LOG_OBJECT (audioresample, "resample gave me %d bytes or %d samples", outsize, outsamples); + GST_BUFFER_OFFSET (outbuf) = audioresample->offset; GST_BUFFER_TIMESTAMP (outbuf) = audioresample->offset * GST_SECOND / audioresample->o_rate; - GST_BUFFER_DURATION (outbuf) = - outsamples * GST_SECOND / audioresample->o_rate; - GST_BUFFER_OFFSET (outbuf) = audioresample->offset; + audioresample->offset += outsamples; GST_BUFFER_OFFSET_END (outbuf) = audioresample->offset; + /* we calculate DURATION as the difference between "next" timestamp + * and current timestamp so we ensure a contiguous stream, instead of + * having rounding errors. */ + GST_BUFFER_DURATION (outbuf) = + audioresample->offset * GST_SECOND / audioresample->o_rate - + GST_BUFFER_TIMESTAMP (outbuf); + /* check for possible mem corruption */ if (outsize > GST_BUFFER_SIZE (outbuf)) { /* this is an error that when it happens, would need fixing in the diff --git a/gst/audioresample/gstaudioresample.h b/gst/audioresample/gstaudioresample.h index 99d937bb..943bc8d8 100644 --- a/gst/audioresample/gstaudioresample.h +++ b/gst/audioresample/gstaudioresample.h @@ -52,7 +52,7 @@ struct _GstAudioresample { gboolean passthru; - gint64 offset; + guint64 offset; int channels; int i_rate; |