[vlc-devel] commit: Still try to splice as many memory pages as possible ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Dec 10 21:28:09 CET 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Wed Dec 10 22:20:25 2008 +0200| [6f029c3e7551e729e0cecda0a89503fcafa5d63f] | committer: Rémi Denis-Courmont 

Still try to splice as many memory pages as possible

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

 modules/stream_filter/decomp.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c
index d571920..d6b9911 100644
--- a/modules/stream_filter/decomp.c
+++ b/modules/stream_filter/decomp.c
@@ -83,7 +83,7 @@ static void *Thread (void *data)
     stream_t *stream = data;
     stream_sys_t *p_sys = stream->p_sys;
 #ifdef __linux__
-    uintptr_t page_mask = sysconf (_SC_PAGE_SIZE) - 1;
+    ssize_t page_mask = sysconf (_SC_PAGE_SIZE) - 1;
 #endif
     int fd = p_sys->write_fd;
     bool error = false;
@@ -108,14 +108,16 @@ static void *Thread (void *data)
 
         for (ssize_t i = 0, j; i < len; i += j)
         {
-            struct iovec iov[1] = { { buf + i, len - i, } };
-
 #ifdef __linux__
-            if (((len | i) & page_mask) == 0)
-                j = vmsplice (fd, iov, 1, SPLICE_F_GIFT);
+            if ((len - i) <= page_mask) /* incomplete last page */
+                j = write (fd, buf + i, len - i);
             else
+            {
+                struct iovec iov = { buf + i, (len - i) & ~page_mask, };
+                j = vmsplice (fd, &iov, 1, SPLICE_F_GIFT);
+            }
 #else
-                j = writev (fd, iov, 1);
+            j = write (fd, buf + i, len - i);
 #endif
             if (j <= 0)
             {




More information about the vlc-devel mailing list