summaryrefslogtreecommitdiffstats
path: root/gst/audioresample/gstaudioresample.c
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2005-08-25 17:20:02 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2005-08-25 17:20:02 +0000
commit7d1ce173830af4c35c654569a232728139dd517e (patch)
treeced3a8d447a190a5fbc71169da4613f20b27b5c2 /gst/audioresample/gstaudioresample.c
parent1dfd2d885647ba0e5b8816f61a6a3617e5aeb834 (diff)
downloadgst-plugins-bad-7d1ce173830af4c35c654569a232728139dd517e.tar.gz
gst-plugins-bad-7d1ce173830af4c35c654569a232728139dd517e.tar.bz2
gst-plugins-bad-7d1ce173830af4c35c654569a232728139dd517e.zip
check/: add a test for audioconvert
Original commit message from CVS: * check/Makefile.am: * check/elements/audioconvert.c: (setup_audioconvert), (cleanup_audioconvert), (get_int_caps), (verify_convert), (GST_START_TEST), (audioconvert_suite), (main): add a test for audioconvert * gst/audioresample/gstaudioresample.c: * gst/audioresample/gstaudioresample.h: set DURATION so that TIMESTAMP(a) + DURATION(a) == TIMESTAMP(b); note that for buffers of 1/3 sec this means DURATION(c) is one nanosecond more than for a and b
Diffstat (limited to 'gst/audioresample/gstaudioresample.c')
-rw-r--r--gst/audioresample/gstaudioresample.c12
1 files changed, 9 insertions, 3 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