]> git.sesse.net Git - vlc/commitdiff
Check for file size change at every read (improve reading of downloading
authorLaurent Aimar <fenrir@videolan.org>
Tue, 22 Jul 2008 20:30:47 +0000 (22:30 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 22 Jul 2008 20:31:41 +0000 (22:31 +0200)
files).

modules/access/mmap.c

index 9f358546f541299b319d806a255db47b14eefb75..887c0bc28e0e01cbb0ea9af6ee9714bbe57d97b3 100644 (file)
@@ -163,25 +163,22 @@ static block_t *Block (access_t *p_access)
 {
     access_sys_t *p_sys = p_access->p_sys;
 
+    /* Check if file size changed... */
+    struct stat st;
+
+    if ((fstat (p_sys->fd, &st) == 0)
+     && (st.st_size != p_access->info.i_size))
+    {
+        p_access->info.i_size = st.st_size;
+        p_access->info.i_update |= INPUT_UPDATE_SIZE;
+    }
+
     if ((uint64_t)p_access->info.i_pos >= (uint64_t)p_access->info.i_size)
     {
-        /* End of file - check if file size changed... */
-        struct stat st;
-
-        if ((fstat (p_sys->fd, &st) == 0)
-         && (st.st_size != p_access->info.i_size))
-        {
-            p_access->info.i_size = st.st_size;
-            p_access->info.i_update |= INPUT_UPDATE_SIZE;
-        }
-
-        /* Really at end of file then */
-        if ((uint64_t)p_access->info.i_pos >= (uint64_t)p_access->info.i_size)
-        {
-            p_access->info.b_eof = true;
-            msg_Dbg (p_access, "at end of memory mapped file");
-            return NULL;
-        }
+        /* We are at end of file */
+        p_access->info.b_eof = true;
+        msg_Dbg (p_access, "at end of memory mapped file");
+        return NULL;
     }
 
 #ifdef MMAP_DEBUG