[vlc-devel] commit: Check for file size change at every read ( improve reading of downloading (Laurent Aimar )
git version control
git at videolan.org
Tue Jul 22 22:29:24 CEST 2008
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Jul 22 22:30:47 2008 +0200| [7a2cfda9e3d5f99a93f3019eab4ed77052ebf307]
Check for file size change at every read (improve reading of downloading
files).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7a2cfda9e3d5f99a93f3019eab4ed77052ebf307
---
modules/access/mmap.c | 31 ++++++++++++++-----------------
1 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/modules/access/mmap.c b/modules/access/mmap.c
index 9f35854..887c0bc 100644
--- a/modules/access/mmap.c
+++ b/modules/access/mmap.c
@@ -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
More information about the vlc-devel
mailing list