summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-10 01:13:40 +0100
committerwm4 <wm4@nowhere>2014-03-10 01:13:40 +0100
commitd842b017e41cd6c70ecb6c5dfb78b0d568448a33 (patch)
tree6e6010d867926f6b85d7a53f741f0835c21dfe6c /audio/out/ao.c
parent4c19c71b85d7c52648feaa6dee599d84f9810da4 (diff)
downloadmpv-d842b017e41cd6c70ecb6c5dfb78b0d568448a33.tar.bz2
mpv-d842b017e41cd6c70ecb6c5dfb78b0d568448a33.tar.xz
audio/out: reduce amount of audio buffering
Since the addition of the AO feed thread, 200ms of latency (MIN_BUFFER) was added to all push-based AOs. This is not so nice, because even AOs with relatively small buffering (e.g. ao_alsa on my system with ~170ms of buffer size), the additional latency becomes noticable when e.g. toggling mute with softvol. Fix this by trying to keep not only 200ms minimum buffer, but also 200ms maximum buffer. In other words, never buffer beyond 200ms in total. Do this by estimating the AO's buffer fill status using get_space and the initially known AO buffer size (the get_space return value on initialization, before any audio was played). We limit the maximum amount of data written to the soft buffer so that soft buffer size and audio buffer size equal to 200ms (MIN_BUFFER). To avoid weird problems with weird AOs, we buffer beyond MIN_BUFFER if the AO's get_space requests more data than that, and as long as the soft buffer is large enough. Note that this is just a hack to improve the latency. When the audio chain gains the ability to refilter data, this won't be needed anymore, and instead we can introduce some sort of buffer replacement function in order to update data in the soft buffer.
Diffstat (limited to 'audio/out/ao.c')
-rw-r--r--audio/out/ao.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index ee8bc2a254..d48b266122 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -36,9 +36,6 @@
#include "common/common.h"
#include "common/global.h"
-// Minimum buffer size in seconds.
-#define MIN_BUFFER 0.2
-
extern const struct ao_driver audio_out_oss;
extern const struct ao_driver audio_out_coreaudio;
extern const struct ao_driver audio_out_rsound;