[vlc-commits] access: make access_GetSize() return an error code

Rémi Denis-Courmont git at videolan.org
Mon Aug 31 17:45:05 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 31 18:32:49 2015 +0300| [8540635824a9cb3bc296229e21e3aa365270181c] | committer: Rémi Denis-Courmont

access: make access_GetSize() return an error code

So far, it was returning zero on error. That prevented distinction
between an empty file and a file with unknown size.

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

 include/vlc_access.h    |    7 ++-----
 modules/access/concat.c |    8 ++++++--
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/vlc_access.h b/include/vlc_access.h
index 0e6ce86..1b42073 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -233,12 +233,9 @@ static inline int access_Control( access_t *p_access, int i_query, ... )
     return i_result;
 }
 
-static inline uint64_t access_GetSize( access_t *p_access )
+static inline int access_GetSize( access_t *p_access, uint64_t *size )
 {
-    uint64_t val;
-    if( access_Control( p_access, ACCESS_GET_SIZE, &val ) )
-        val = 0;
-    return val;
+    return access_Control( p_access, ACCESS_GET_SIZE, size );
 }
 
 static inline void access_InitFields( access_t *p_a )
diff --git a/modules/access/concat.c b/modules/access/concat.c
index c008619..93c96ed 100644
--- a/modules/access/concat.c
+++ b/modules/access/concat.c
@@ -156,8 +156,10 @@ static int Seek(access_t *access, uint64_t position)
         if (!can_seek)
             break;
 
-        uint64_t size = access_GetSize(a);
+        uint64_t size;
 
+        if (access_GetSize(a, &size))
+            size = 0;
         if (position - access->info.i_pos < size)
         {
             if (vlc_access_Seek(a, position - access->info.i_pos))
@@ -281,7 +283,9 @@ static int Open(vlc_object_t *obj)
         if (sys->can_control_pace)
             access_Control(a, ACCESS_CAN_CONTROL_PACE, &sys->can_control_pace);
 
-        sys->size += access_GetSize(a);
+        uint64_t size;
+        if (access_GetSize(a, &size) == 0)
+            sys->size += size;
 
         int64_t caching;
         access_Control(a, ACCESS_GET_PTS_DELAY, &caching);



More information about the vlc-commits mailing list