mirror of
https://github.com/mpv-player/mpv
synced 2024-12-19 05:15:12 +00: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:
parent
b0b0e69570
commit
7221d96ba3
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user