summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-17 21:47:00 +0200
committerwm4 <wm4@nowhere>2014-04-17 21:47:00 +0200
commit9dba2a52db2adb42e7c1a292625bd0114ce81969 (patch)
tree6ea6a9410a4741bbb8e2c2c4cfff39c0172c3425 /audio
parent6c24a80009025cbaf1e71a753b7c5572ba89b71f (diff)
downloadmpv-9dba2a52db2adb42e7c1a292625bd0114ce81969.tar.bz2
mpv-9dba2a52db2adb42e7c1a292625bd0114ce81969.tar.xz
player: add a --dump-stats option
This collects statistics and other things. The option dumps raw data into a file. A script to visualize this data is included too. Litter some of the player code with calls that generate these statistics. In general, this will be helpful to debug timing dependent issues, such as A/V sync problems. Normally, one could argue that this is the task of a real profiler, but then we'd have a hard time to include extra information like audio/video PTS differences. We could also just hardcode all statistics collection and processing in the player code, but then we'd end up with something like mplayer's status line, which was cluttered and required a centralized approach (i.e. getting the data to the status line; so it was all in mplayer.c). Some players can visualize such statistics on OSD, but that sounds even more complicated. So the approach added with this commit sounds sensible. The stats-conv.py script is rather primitive at the moment and its output is semi-ugly. It uses matplotlib, so it could probably be extended to do a lot, so it's not a dead-end.
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/dec_audio.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index b44216ec00..46009c6fdd 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -317,7 +317,9 @@ int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
double filter_multiplier = af_calc_filter_multiplier(d_audio->afilter);
int prev_buffered = -1;
- while (minsamples >= 0) {
+ int res = 0;
+ MP_STATS(d_audio, "start audio");
+ while (res >= 0 && minsamples >= 0) {
int buffered = mp_audio_buffer_samples(outbuf);
if (minsamples < buffered || buffered == prev_buffered)
break;
@@ -343,11 +345,10 @@ int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
* of buffering in filters */
huge_filter_buffer = 1;
- int res = filter_n_bytes(d_audio, outbuf, decsamples);
- if (res < 0)
- return res;
+ res = filter_n_bytes(d_audio, outbuf, decsamples);
}
- return 0;
+ MP_STATS(d_audio, "end audio");
+ return res;
}
void audio_reset_decoding(struct dec_audio *d_audio)