[vlc-commits] prefetch: don't do anything when reading 0 bytes

Steve Lhomme git at videolan.org
Mon Feb 8 17:31:51 CET 2016


vlc | branch: master | Steve Lhomme <robUx4 at gmail.com> | Mon Feb  8 16:48:22 2016 +0100| [e1588d2c037d97f4c7a052e9871ab26f1de61a13] | committer: Rémi Denis-Courmont

prefetch: don't do anything when reading 0 bytes

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e1588d2c037d97f4c7a052e9871ab26f1de61a13
---

 modules/stream_filter/prefetch.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/modules/stream_filter/prefetch.c b/modules/stream_filter/prefetch.c
index 4821140..b3bc859 100644
--- a/modules/stream_filter/prefetch.c
+++ b/modules/stream_filter/prefetch.c
@@ -307,6 +307,8 @@ static ssize_t Read(stream_t *stream, void *buf, size_t buflen)
     size_t copy;
     bool eof;
 
+    if (buflen == 0)
+        return buflen;
     if (buf == NULL)
     {
         Seek(stream, sys->stream_offset + buflen);
@@ -339,12 +341,9 @@ static ssize_t Read(stream_t *stream, void *buf, size_t buflen)
     char *p = sys->buffer + (sys->stream_offset % sys->buffer_size);
     if (copy > buflen)
         copy = buflen;
-    if (copy > 0)
-    {
-        memcpy(buf, p, copy);
-        sys->stream_offset += copy;
-        vlc_cond_signal(&sys->wait_space);
-    }
+    memcpy(buf, p, copy);
+    sys->stream_offset += copy;
+    vlc_cond_signal(&sys->wait_space);
     vlc_mutex_unlock(&sys->lock);
     return copy;
 }



More information about the vlc-commits mailing list