diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2011-01-26 21:48:15 +0000 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2011-02-15 18:35:34 +0200 |
commit | ba3dab46397aa2f65f7678bce88d7bf08fdb6514 (patch) | |
tree | fb4a8623d2ecbdd4b5ff2809e854211d8ecc4f60 | |
parent | 398643d0d712974c132822d97c51615a16f4f1b8 (diff) | |
download | mpv-ba3dab46397aa2f65f7678bce88d7bf08fdb6514.tar.bz2 mpv-ba3dab46397aa2f65f7678bce88d7bf08fdb6514.tar.xz |
terminal output: show cache fill changes in "PAUSED" message
Convert cache_fill_status into a function so we always get the latest
state, not whatever it was after the last read.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32818 b3059339-0415-0410-9bf9-f77b7e298cf2
Update PAUSED status line with cache fill status if it changed.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32819 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | mplayer.c | 23 | ||||
-rw-r--r-- | stream/cache2.c | 11 | ||||
-rw-r--r-- | stream/cache2.h | 3 |
3 files changed, 31 insertions, 6 deletions
@@ -1323,7 +1323,7 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame) #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 @@ -2865,6 +2865,10 @@ static void pause_loop(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; mp_cmd_t* cmd; +#ifdef CONFIG_STREAM_CACHE + int old_cache_fill = stream_cache_size > 0 ? + cache_fill_status(mpctx->stream) : 0; +#endif if (!opts->quiet) { if (opts->term_osd && !mpctx->sh_video) { set_osd_tmsg(OSD_MSG_PAUSE, 1, 0, " ===== PAUSE ====="); @@ -2895,6 +2899,23 @@ static void pause_loop(struct MPContext *mpctx) vo_osd_changed(hack); if (hack) break; +#ifdef CONFIG_STREAM_CACHE + if (!opts->quiet && stream_cache_size > 0) { + int new_cache_fill = cache_fill_status(mpctx->stream); + if (new_cache_fill != old_cache_fill) { + if (opts->term_osd && !mpctx->sh_video) { + set_osd_tmsg(OSD_MSG_PAUSE, 1, 0, "%s %d%%", + mp_gtext(" ===== PAUSE ====="), + new_cache_fill); + update_osd_msg(mpctx); + } else + mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s %d%%\r", + mp_gtext(" ===== PAUSE ====="), + new_cache_fill); + old_cache_fill = new_cache_fill; + } + } +#endif } } diff --git a/stream/cache2.c b/stream/cache2.c index 9e87670752..9e4bea35b4 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -95,8 +95,6 @@ typedef struct { static int min_fill=0; -int cache_fill_status=0; - static void cache_wakeup(stream_t *s) { #if FORKED_CACHE @@ -161,7 +159,6 @@ static int cache_read(cache_vars_t *s, unsigned char *buf, int size) total+=len; } - cache_fill_status=(s->max_filepos-s->read_filepos)/(s->buffer_size / 100); return total; } @@ -511,6 +508,14 @@ int cache_stream_fill_buffer(stream_t *s){ } +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; diff --git a/stream/cache2.h b/stream/cache2.h index 2e6a4e0dbb..9c98193f0c 100644 --- a/stream/cache2.h +++ b/stream/cache2.h @@ -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 */ |