Browse code

cache: Fallback to using the cache size for AVSEEK_SIZE if the underlaying protocol has nothing better.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/10/16 23:54:27
Showing 1 changed files
... ...
@@ -95,7 +95,14 @@ static int64_t cache_seek(URLContext *h, int64_t pos, int whence)
95 95
     Context *c= h->priv_data;
96 96
 
97 97
     if (whence == AVSEEK_SIZE) {
98
-        return ffurl_seek(c->inner, pos, whence);
98
+        pos= ffurl_seek(c->inner, pos, whence);
99
+        if(pos <= 0){
100
+            pos= ffurl_seek(c->inner, -1, SEEK_END);
101
+            ffurl_seek(c->inner, c->end, SEEK_SET);
102
+            if(pos <= 0)
103
+                return c->end;
104
+        }
105
+        return pos;
99 106
     }
100 107
 
101 108
     pos= lseek(c->fd, pos, whence);