summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-10 21:30:40 +0100
committerwm4 <wm4@nowhere>2014-03-10 22:56:23 +0100
commit7221d96ba311404f54752937253f210fb53623ea (patch)
tree54f23a1f21f187952fc86eccb5bf801d6601bc0d /audio
parentb0b0e6957089b2031eba60bcfdb28eaf6b59012d (diff)
downloadmpv-7221d96ba311404f54752937253f210fb53623ea.tar.bz2
mpv-7221d96ba311404f54752937253f210fb53623ea.tar.xz
ao_sdl: make sure our buffer is always larger than what SDL requests
Assume obtained.samples contains the number of samples the SDL audio callback will request at once. Then make sure ao.c will set the buffer size at least to 3 times that value (or more). Might help with bad SDL audio backends like ESD, which supposedly uses a 500ms buffer.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_sdl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/audio/out/ao_sdl.c b/audio/out/ao_sdl.c
index 1b229d2090..95f1a0d24d 100644
--- a/audio/out/ao_sdl.c
+++ b/audio/out/ao_sdl.c
@@ -150,6 +150,12 @@ static int init(struct ao *ao)
(int) obtained.freq, (int) obtained.channels,
(int) obtained.format, (int) obtained.samples);
+ // The sample count is usually the number of samples the callback requests,
+ // which we assume is the period size. Normally, ao.c will allocate a large
+ // enough buffer. But in case the period size should be pathologically
+ // large, this will help.
+ ao->device_buffer = 3 * obtained.samples;
+
switch (obtained.format) {
case AUDIO_U8: ao->format = AF_FORMAT_U8; break;
case AUDIO_S8: ao->format = AF_FORMAT_S8; break;