From a4df733d527d28ed42869bedf5b06436e46726ac Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 24 May 2003 11:04:57 +0000 Subject: [PATCH] only update the DURATION field when appending buffers and both buffers have a valid duration. Original commit message from CVS: only update the DURATION field when appending buffers and both buffers have a valid duration. --- gst/gstbuffer.c | 8 ++++++-- gst/gstbuffer.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index a0701de7f8..6ffe635221 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -452,8 +452,12 @@ gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len) } } /* if we completely merged the two buffers (appended), we can - * calculate the duration too */ - if (offset == 0 && buf1->size + buf2->size == len) { + * calculate the duration too. Also make sure we's not messing with + * invalid DURATIONS */ + if (offset == 0 && buf1->size + buf2->size == len && + GST_BUFFER_DURATION_IS_VALID (buf1) && + GST_BUFFER_DURATION_IS_VALID (buf2)) + { /* add duration */ GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) + GST_BUFFER_DURATION (buf2); diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 8f8a6a8151..aaa732b870 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -69,6 +69,7 @@ extern GType _gst_buffer_pool_type; #define GST_BUFFER_OFFSET_NONE ((guint64)-1) #define GST_BUFFER_MAXSIZE_NONE ((guint)0) +#define GST_BUFFER_DURATION_IS_VALID(buffer) (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer))) #define GST_BUFFER_TIMESTAMP_IS_VALID(buffer) (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer))) #define GST_BUFFER_OFFSET_IS_VALID(buffer) (GST_BUFFER_OFFSET (buffer) != GST_BUFFER_OFFSET_NONE) #define GST_BUFFER_MAXSIZE_IS_VALID(buffer) (GST_BUFFER_MAXSIZE (buffer) != GST_BUFFER_MAXSIZE_NONE)