summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2008-03-10 17:19:56 +0000
committerWim Taymans <wim.taymans@gmail.com>2008-03-10 17:19:56 +0000
commit579949e2c5458f4b378a13dc8bc55b98eee3aea9 (patch)
tree31b5f9adb3b15845f7a923fe59c4882f232c48d6
parentcf273d8add57d03273514597a07eaeaf762b931b (diff)
downloadgstreamer-plugins-base-579949e2c5458f4b378a13dc8bc55b98eee3aea9.tar.gz
gst-libs/gst/audio/gstbaseaudiosrc.c: Fix duration when no clock was provided. Fixes #520300.
Original commit message from CVS: * gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_create): Fix duration when no clock was provided. Fixes #520300.
-rw-r--r--ChangeLog6
m---------common0
-rw-r--r--gst-libs/gst/audio/gstbaseaudiosrc.c21
3 files changed, 17 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 16ed6b7d0..730c0257d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-03-10 Wim Taymans <wim.taymans@collabora.co.uk>
+
+ * gst-libs/gst/audio/gstbaseaudiosrc.c:
+ (gst_base_audio_src_create):
+ Fix duration when no clock was provided. Fixes #520300.
+
2008-03-07 Wim Taymans <wim.taymans@collabora.co.uk>
Patch by: Olivier Crete <tester at tester ca>
diff --git a/common b/common
-Subproject e02bd43fe6b9e45536eccbf5b7a5f9eae62030f
+Subproject 170f8e91adc7157f6e708ffa58ca22d10e4e45d
diff --git a/gst-libs/gst/audio/gstbaseaudiosrc.c b/gst-libs/gst/audio/gstbaseaudiosrc.c
index 5716984b1..0ab03c1c8 100644
--- a/gst-libs/gst/audio/gstbaseaudiosrc.c
+++ b/gst-libs/gst/audio/gstbaseaudiosrc.c
@@ -598,7 +598,7 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
GstRingBuffer *ringbuffer;
GstRingBufferSpec *spec;
guint read;
- GstClockTime timestamp;
+ GstClockTime timestamp, duration;
GstClock *clock;
ringbuffer = src->ringbuffer;
@@ -669,18 +669,21 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
}
+ src->next_sample = sample + samples;
+
+ /* get the normal timestamp to get the duration. */
+ timestamp = gst_util_uint64_scale_int (sample, GST_SECOND, spec->rate);
+ duration = gst_util_uint64_scale_int (src->next_sample, GST_SECOND,
+ spec->rate) - timestamp;
+
GST_OBJECT_LOCK (src);
clock = GST_ELEMENT_CLOCK (src);
- if (clock == NULL || clock == src->clock) {
- /* timestamp against our own clock. We do this also when no external clock
- * was provided to us. */
- timestamp = gst_util_uint64_scale_int (sample, GST_SECOND, spec->rate);
- } else {
+ if (clock != NULL && clock != src->clock) {
GstClockTime base_time, latency;
/* We are slaved to another clock, take running time of the clock and just
* timestamp against it. Somebody else in the pipeline should figure out the
- * clock drift, for now. */
+ * clock drift, for now. We keep the duration we calculated above. */
timestamp = gst_clock_get_time (clock);
base_time = GST_ELEMENT_CAST (src)->base_time;
@@ -699,9 +702,7 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
GST_OBJECT_UNLOCK (src);
GST_BUFFER_TIMESTAMP (buf) = timestamp;
- src->next_sample = sample + samples;
- GST_BUFFER_DURATION (buf) = gst_util_uint64_scale_int (src->next_sample,
- GST_SECOND, spec->rate) - GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (buf) = duration;
GST_BUFFER_OFFSET (buf) = sample;
GST_BUFFER_OFFSET_END (buf) = sample + samples;