From cf5de908fbebc900e91a4a7e799b857817f74a49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 25 Dec 2011 12:29:46 +0000 Subject: [PATCH] filesrc: minor cosmetic changes Rename woffset variable, maintain separate bytes_read in addition to length variable. --- plugins/elements/gstfilesrc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index d2b88c6..9844f0d 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -800,7 +800,7 @@ gst_file_src_create_read (GstFileSrc * src, guint64 offset, guint length, { int ret; GstBuffer *buf; - guint64 woffset; + guint to_read, bytes_read; if (G_UNLIKELY (src->read_position != offset)) { off_t res; @@ -822,12 +822,13 @@ gst_file_src_create_read (GstFileSrc * src, guint64 offset, guint length, GST_BUFFER_SIZE (buf) = 0; GST_BUFFER_OFFSET (buf) = offset; GST_BUFFER_OFFSET_END (buf) = offset; - woffset = 0; - while (length > 0) { + bytes_read = 0; + to_read = length; + while (to_read > 0) { GST_LOG_OBJECT (src, "Reading %d bytes at offset 0x%" G_GINT64_MODIFIER "x", - length, offset + woffset); + to_read, offset + bytes_read); errno = 0; - ret = read (src->fd, GST_BUFFER_DATA (buf) + woffset, length); + ret = read (src->fd, GST_BUFFER_DATA (buf) + bytes_read, to_read); if (G_UNLIKELY (ret < 0)) { if (errno == EAGAIN || errno == EINTR) continue; @@ -838,14 +839,15 @@ gst_file_src_create_read (GstFileSrc * src, guint64 offset, guint length, if (G_UNLIKELY (ret == 0)) goto eos; - length -= ret; - woffset += ret; - GST_BUFFER_SIZE (buf) += ret; - GST_BUFFER_OFFSET_END (buf) += ret; + to_read -= ret; + bytes_read += ret; src->read_position += ret; } + GST_BUFFER_SIZE (buf) = bytes_read; + GST_BUFFER_OFFSET_END (buf) = offset + bytes_read; + *buffer = buf; return GST_FLOW_OK; -- 2.7.4