changeset 32731:005b026b1231

Convert cache_fill_status into a function so we always get the latest state, not whatever it was after the last read.
author reimar
date Wed, 26 Jan 2011 21:48:15 +0000
parents 736b22f11e00
children 67e0128e2f1a
files mplayer.c stream/cache2.c stream/cache2.h
diffstat 3 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mplayer.c	Wed Jan 26 21:24:49 2011 +0000
+++ b/mplayer.c	Wed Jan 26 21:48:15 2011 +0000
@@ -1280,7 +1280,7 @@
 #ifdef CONFIG_STREAM_CACHE
   // cache stats
   if (stream_cache_size > 0)
-    saddf(line, &pos, width, "%d%% ", cache_fill_status);
+    saddf(line, &pos, width, "%d%% ", cache_fill_status(mpctx->stream));
 #endif
 
   // other
--- a/stream/cache2.c	Wed Jan 26 21:24:49 2011 +0000
+++ b/stream/cache2.c	Wed Jan 26 21:48:15 2011 +0000
@@ -96,8 +96,6 @@
 
 static int min_fill=0;
 
-int cache_fill_status=0;
-
 static void cache_wakeup(stream_t *s)
 {
 #if FORKED_CACHE
@@ -162,7 +160,6 @@
     total+=len;
 
   }
-  cache_fill_status=(s->max_filepos-s->read_filepos)/(s->buffer_size / 100);
   return total;
 }
 
@@ -513,6 +510,14 @@
 
 }
 
+int cache_fill_status(stream_t *s) {
+  cache_vars_t *cv;
+  if (!s || !s->cache_data)
+    return -1;
+  cv = s->cache_data;
+  return (cv->max_filepos-cv->read_filepos)/(cv->buffer_size / 100);
+}
+
 int cache_stream_seek_long(stream_t *stream,off_t pos){
   cache_vars_t* s;
   off_t newpos;
--- a/stream/cache2.h	Wed Jan 26 21:24:49 2011 +0000
+++ b/stream/cache2.h	Wed Jan 26 21:48:15 2011 +0000
@@ -21,9 +21,8 @@
 
 #include "stream.h"
 
-extern int cache_fill_status;
-
 void cache_uninit(stream_t *s);
 int cache_do_control(stream_t *stream, int cmd, void *arg);
+int cache_fill_status(stream_t *s);
 
 #endif /* MPLAYER_CACHE2_H */