summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-24 11:34:38 +0200
committerwm4 <wm4@nowhere>2013-06-24 11:36:15 +0200
commit536871d7e5848eb385b97202a33b9382b5e8ab0e (patch)
treeb3d4ea80d19800645764e1d5c885f0eab8161344
parent9a83d03c5d8d6f73fd41707eb9775be1af3d3daf (diff)
downloadmpv-536871d7e5848eb385b97202a33b9382b5e8ab0e.tar.bz2
mpv-536871d7e5848eb385b97202a33b9382b5e8ab0e.tar.xz
cache: cache number of chapters
Querying this caused the cache to block and wait. Some parts of the frontend (like progress bar) call this very often, so cache performance was ruined in these cases. Also print a message in -v mode when the cache is blocked for a STREAM_CTRL. This should make debugging similar issues easier.
-rw-r--r--stream/cache.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/stream/cache.c b/stream/cache.c
index d93d539494..9a9c6b9a00 100644
--- a/stream/cache.c
+++ b/stream/cache.c
@@ -99,6 +99,7 @@ struct priv {
double stream_start_time;
int64_t stream_size;
bool stream_manages_timeline;
+ unsigned int stream_num_chapters;
int stream_cache_idle;
int stream_cache_fill;
};
@@ -303,6 +304,7 @@ static bool cache_fill(struct priv *s)
static void update_cached_controls(struct priv *s)
{
+ unsigned int ui;
double d;
s->stream_time_length = 0;
if (stream_control(s->stream, STREAM_CTRL_GET_TIME_LENGTH, &d) == STREAM_OK)
@@ -313,6 +315,9 @@ static void update_cached_controls(struct priv *s)
s->stream_manages_timeline = false;
if (stream_control(s->stream, STREAM_CTRL_MANAGES_TIMELINE, NULL) == STREAM_OK)
s->stream_manages_timeline = true;
+ s->stream_num_chapters = 0;
+ if (stream_control(s->stream, STREAM_CTRL_GET_NUM_CHAPTERS, &ui) == STREAM_OK)
+ s->stream_num_chapters = ui;
stream_update_size(s->stream);
s->stream_size = s->stream->end_pos;
}
@@ -343,6 +348,9 @@ static int cache_get_cached_control(stream_t *cache, int cmd, void *arg)
return STREAM_OK;
case STREAM_CTRL_MANAGES_TIMELINE:
return s->stream_manages_timeline ? STREAM_OK : STREAM_UNSUPPORTED;
+ case STREAM_CTRL_GET_NUM_CHAPTERS:
+ *(unsigned int *)arg = s->stream_num_chapters;
+ return STREAM_OK;
case STREAM_CTRL_GET_CURRENT_TIME: {
if (s->read_filepos >= s->min_filepos &&
s->read_filepos <= s->max_filepos &&
@@ -478,6 +486,8 @@ static int cache_control(stream_t *cache, int cmd, void *arg)
if (r != STREAM_ERROR)
goto done;
+ mp_msg(MSGT_CACHE, MSGL_V, "[cache] blocking for STREAM_CTRL %d\n", cmd);
+
s->control = cmd;
s->control_arg = arg;
double retry = 0;