summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-10-26 22:23:50 +0200
committerwm4 <wm4@nowhere>2019-10-26 22:23:50 +0200
commitd39a12a4f75a9035c7819723f959900731ea66e6 (patch)
tree95cabfbc811dd59dbaa05811242057604e3accad
parent9624531b20c6a8bee58ffdcdcb532b17bad0dfed (diff)
downloadmpv-d39a12a4f75a9035c7819723f959900731ea66e6.tar.bz2
mpv-d39a12a4f75a9035c7819723f959900731ea66e6.tar.xz
stats, demux: log byte level stream seeks
Helpful for debugging that mp4 issue.
-rw-r--r--demux/demux.c7
-rw-r--r--demux/demux.h1
-rw-r--r--player/command.c1
-rw-r--r--player/lua/stats.lua1
-rw-r--r--stream/stream.c2
-rw-r--r--stream/stream.h2
6 files changed, 14 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 01f15de496..b6a4bc5643 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -273,6 +273,7 @@ struct demux_internal {
int64_t slave_unbuffered_read_bytes; // value repoted from demuxer impl.
int64_t hack_unbuffered_read_bytes; // for demux_get_bytes_read_hack()
int64_t cache_unbuffered_read_bytes; // for demux_reader_state.bytes_per_second
+ int64_t byte_level_seeks; // for demux_reader_state.byte_level_seeks
};
struct timed_metadata {
@@ -3977,14 +3978,19 @@ static void update_bytes_read(struct demux_internal *in)
int64_t new = in->slave_unbuffered_read_bytes;
in->slave_unbuffered_read_bytes = 0;
+ int64_t new_seeks = 0;
+
struct stream *stream = demuxer->stream;
if (stream) {
new += stream->total_unbuffered_read_bytes;
stream->total_unbuffered_read_bytes = 0;
+ new_seeks += stream->total_stream_seeks;
+ stream->total_stream_seeks = 0;
}
in->cache_unbuffered_read_bytes += new;
in->hack_unbuffered_read_bytes += new;
+ in->byte_level_seeks += new_seeks;
}
// must be called not locked
@@ -4345,6 +4351,7 @@ void demux_get_reader_state(struct demuxer *demuxer, struct demux_reader_state *
.low_level_seeks = in->low_level_seeks,
.ts_last = in->demux_ts,
.bytes_per_second = in->bytes_per_second,
+ .byte_level_seeks = in->byte_level_seeks,
.file_cache_bytes = in->cache ? demux_cache_get_size(in->cache) : -1,
};
bool any_packets = false;
diff --git a/demux/demux.h b/demux/demux.h
index 3e3abbc84f..235744c6f7 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -47,6 +47,7 @@ struct demux_reader_state {
int64_t file_cache_bytes;
double seeking; // current low level seek target, or NOPTS
int low_level_seeks; // number of started low level seeks
+ uint64_t byte_level_seeks; // number of byte stream level seeks
double ts_last; // approx. timestamp of demuxer position
uint64_t bytes_per_second; // low level statistics
// Positions that can be seeked to without incurring the latency of a low
diff --git a/player/command.c b/player/command.c
index 1d0da8e105..8c77344f6b 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1548,6 +1548,7 @@ static int mp_property_demuxer_cache_state(void *ctx, struct m_property *prop,
if (s.seeking != MP_NOPTS_VALUE)
node_map_add_double(r, "debug-seeking", s.seeking);
node_map_add_int64(r, "debug-low-level-seeks", s.low_level_seeks);
+ node_map_add_int64(r, "debug-byte-level-seeks", s.byte_level_seeks);
if (s.ts_last != MP_NOPTS_VALUE)
node_map_add_double(r, "debug-ts-last", s.ts_last);
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 8df192db2a..a1cd566ab5 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -674,6 +674,7 @@ local function cache_stats()
append(stats, fc, {prefix = "Disk cache:"})
append(stats, info["debug-low-level-seeks"], {prefix = "Media seeks:"})
+ append(stats, info["debug-byte-level-seeks"], {prefix = "Stream seeks:"})
append(stats, "", {prefix=o.nl .. o.nl .. "Ranges:", nl="", indent=""})
diff --git a/stream/stream.c b/stream/stream.c
index 7fea12f01f..3557e488d0 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -706,6 +706,8 @@ static bool stream_seek_unbuffered(stream_t *s, int64_t newpos)
MP_VERBOSE(s, "stream level seek from %" PRId64 " to %" PRId64 "\n",
s->pos, newpos);
+ s->total_stream_seeks++;
+
if (newpos > s->pos && !s->seekable) {
MP_ERR(s, "Cannot seek forward in this stream\n");
return false;
diff --git a/stream/stream.h b/stream/stream.h
index 8aa45c821f..2d79b636ef 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -146,6 +146,8 @@ typedef struct stream {
// Read statistic for fill_buffer calls. All bytes read by fill_buffer() are
// added to this. The user can reset this as needed.
uint64_t total_unbuffered_read_bytes;
+ // Seek statistics. The user can reset this as needed.
+ uint64_t total_stream_seeks;
// Buffer size requested by user; s->buffer may have a different size
int requested_buffer_size;