From 7221d96ba311404f54752937253f210fb53623ea Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 10 Mar 2014 21:30:40 +0100 Subject: 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. --- audio/out/ao_sdl.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'audio/out/ao_sdl.c') 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; -- cgit v1.2.3