0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

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.
This commit is contained in:
wm4 2014-03-10 21:30:40 +01:00
parent b0b0e69570
commit 7221d96ba3

View File

@ -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;