From 875b25482c0ff66ebc78898bc80f390f05ac774f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 4 Nov 2005 15:33:40 +0000 Subject: [PATCH] gst/base/gstbasesrc.c: Small update to stop at the configured segment_end position. Original commit message from CVS: * gst/base/gstbasesrc.c: (gst_base_src_get_range): Small update to stop at the configured segment_end position. --- ChangeLog | 6 ++++++ gst/base/gstbasesrc.c | 28 +++++++++++++++++++--------- libs/gst/base/gstbasesrc.c | 28 +++++++++++++++++++--------- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fba5cd389..5885aff1f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-11-04 Wim Taymans + + * gst/base/gstbasesrc.c: (gst_base_src_get_range): + Small update to stop at the configured segment_end + position. + 2005-11-04 Stefan Kost * gst/gstregistry.c: diff --git a/gst/base/gstbasesrc.c b/gst/base/gstbasesrc.c index 32811dec86..f005e1f29b 100644 --- a/gst/base/gstbasesrc.c +++ b/gst/base/gstbasesrc.c @@ -786,6 +786,7 @@ gst_base_src_get_range (GstBaseSrc * src, guint64 offset, guint length, { GstFlowReturn ret; GstBaseSrcClass *bclass; + gint64 maxsize; bclass = GST_BASE_SRC_GET_CLASS (src); @@ -816,21 +817,30 @@ gst_base_src_get_range (GstBaseSrc * src, guint64 offset, guint length, "reading offset %" G_GUINT64_FORMAT ", length %u, size %" G_GINT64_FORMAT, offset, length, src->size); + /* the max amount of bytes to read is the total size or + * up to the segment_end if present. */ + if (src->segment_end != -1) + maxsize = MIN (src->size, src->segment_end); + else + maxsize = src->size; + /* check size */ - if (src->size != -1) { - if (offset > src->size) + if (maxsize != -1) { + if (offset > maxsize) goto unexpected_length; - /* is segment done ? */ - if (src->segment_loop && (offset > src->segment_end)) - goto unexpected_length; - - if (offset + length > src->size) { + if (offset + length > maxsize) { + /* see if length of the file changed */ if (bclass->get_size) bclass->get_size (src, &src->size); - if (offset + length > src->size) { - length = src->size - offset; + if (src->segment_end != -1) + maxsize = MIN (src->size, src->segment_end); + else + maxsize = src->size; + + if (offset + length > maxsize) { + length = maxsize - offset; } } } diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index 32811dec86..f005e1f29b 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -786,6 +786,7 @@ gst_base_src_get_range (GstBaseSrc * src, guint64 offset, guint length, { GstFlowReturn ret; GstBaseSrcClass *bclass; + gint64 maxsize; bclass = GST_BASE_SRC_GET_CLASS (src); @@ -816,21 +817,30 @@ gst_base_src_get_range (GstBaseSrc * src, guint64 offset, guint length, "reading offset %" G_GUINT64_FORMAT ", length %u, size %" G_GINT64_FORMAT, offset, length, src->size); + /* the max amount of bytes to read is the total size or + * up to the segment_end if present. */ + if (src->segment_end != -1) + maxsize = MIN (src->size, src->segment_end); + else + maxsize = src->size; + /* check size */ - if (src->size != -1) { - if (offset > src->size) + if (maxsize != -1) { + if (offset > maxsize) goto unexpected_length; - /* is segment done ? */ - if (src->segment_loop && (offset > src->segment_end)) - goto unexpected_length; - - if (offset + length > src->size) { + if (offset + length > maxsize) { + /* see if length of the file changed */ if (bclass->get_size) bclass->get_size (src, &src->size); - if (offset + length > src->size) { - length = src->size - offset; + if (src->segment_end != -1) + maxsize = MIN (src->size, src->segment_end); + else + maxsize = src->size; + + if (offset + length > maxsize) { + length = maxsize - offset; } } }