cache: do not include backbuffer size in total stream cache size

This causes weirdness with the "cache-size" property and option. Only
the read handler of the property included the backbuffer, while all
others did not. Make it consistent, and subtract the backbuffer size
from the cache size.

Fixes #2305.
This commit is contained in:
wm4 2015-09-10 14:10:44 +02:00
parent d3bd5c9541
commit 2492b5f119
2 changed files with 4 additions and 2 deletions

View File

@ -1111,11 +1111,13 @@ Property list
Network cache fill state (0-100.0). Network cache fill state (0-100.0).
``cache-size`` (RW) ``cache-size`` (RW)
Total network cache size in KB. This is similar to ``--cache``. This allows Network cache size in KB. This is similar to ``--cache``. This allows
to set the cache size at runtime. Currently, it's not possible to enable to set the cache size at runtime. Currently, it's not possible to enable
or disable the cache at runtime using this property, just to resize an or disable the cache at runtime using this property, just to resize an
existing cache. existing cache.
This does not include the backbuffer size (changed after mpv 0.10.0).
Note that this tries to keep the cache contents as far as possible. To make Note that this tries to keep the cache contents as far as possible. To make
this easier, the cache resizing code will allocate the new cache while the this easier, the cache resizing code will allocate the new cache while the
old cache is still allocated. old cache is still allocated.

View File

@ -367,7 +367,7 @@ static int cache_get_cached_control(stream_t *cache, int cmd, void *arg)
struct priv *s = cache->priv; struct priv *s = cache->priv;
switch (cmd) { switch (cmd) {
case STREAM_CTRL_GET_CACHE_SIZE: case STREAM_CTRL_GET_CACHE_SIZE:
*(int64_t *)arg = s->buffer_size; *(int64_t *)arg = s->buffer_size - s->back_size;
return STREAM_OK; return STREAM_OK;
case STREAM_CTRL_GET_CACHE_FILL: case STREAM_CTRL_GET_CACHE_FILL:
*(int64_t *)arg = s->max_filepos - s->read_filepos; *(int64_t *)arg = s->max_filepos - s->read_filepos;