sdl2_frt/src/audio
Anthony Pesch c591429542 alsa: avoid hardware parameters with an excessive number of periods.
The previous code attempted to use set_buffer_size / set_period_size
discretely, favoring the parameters which generated a buffer size that was
exactly 2x the requested buffer size. This solution ultimately prioritizes
only the buffer size, which comes at a large performance cost on some machines
where this results in an excessive number of periods. In my case, for a 4096
sample buffer, this configured the device to use 37 periods with a period size
of 221 samples and a buffer size of 8192 samples. With 37 periods, the SDL
Audio thread was consuming 25% of the CPU.

This code has been refactored to use set_period_size and set_buffer_size
together. set_period_size is called first to attempt to set the period to
exactly match the requested buffer size, and set_buffer_size is called second
to further refine the parameters to attempt to use only 2 periods. The
fundamental change here is that the period size / count won't go to extreme
values if the buffer size can't be exactly matched, the buffer size should
instead just increase to the next closest multiple of the target period size
that is supported. After changing this, for a 4096 sample buffer, the device
is configured to use 3 periods with a period size of 4096 samples and a buffer
size of 12288 samples. With only 3 periods, the SDL Audio thread doesn't even
show up when profiling.

Fixes Bugzilla #4156.
2018-05-04 21:21:32 -04:00
..
alsa alsa: avoid hardware parameters with an excessive number of periods. 2018-05-04 21:21:32 -04:00
android Updated copyright for 2018 2018-01-03 10:03:25 -08:00
arts Updated copyright for 2018 2018-01-03 10:03:25 -08:00
coreaudio Fixed bug 4169 - Crash due to audio session observer race condition 2018-05-24 07:30:24 -07:00
directsound revert the recent typecast assignment changes (see bug #4079) 2018-02-12 17:00:00 +03:00
disk Updated copyright for 2018 2018-01-03 10:03:25 -08:00
dsp Updated copyright for 2018 2018-01-03 10:03:25 -08:00
dummy Updated copyright for 2018 2018-01-03 10:03:25 -08:00
emscripten Updated copyright for 2018 2018-01-03 10:03:25 -08:00
esd Updated copyright for 2018 2018-01-03 10:03:25 -08:00
fusionsound Updated copyright for 2018 2018-01-03 10:03:25 -08:00
haiku Updated copyright for 2018 2018-01-03 10:03:25 -08:00
jack Fixed bug 4184 - jack audio driver fails in presence of midi ports 2018-06-01 19:43:53 -07:00
nacl Updated copyright for 2018 2018-01-03 10:03:25 -08:00
nas Updated copyright for 2018 2018-01-03 10:03:25 -08:00
netbsd Updated copyright for 2018 2018-01-03 10:03:25 -08:00
paudio Updated copyright for 2018 2018-01-03 10:03:25 -08:00
psp Updated copyright for 2018 2018-01-03 10:03:25 -08:00
pulseaudio pulseaudio: Just read/dump captured data in FlushCapture. 2018-02-17 18:30:21 -05:00
qsa Updated copyright for 2018 2018-01-03 10:03:25 -08:00
sndio Updated copyright for 2018 2018-01-03 10:03:25 -08:00
sun Updated copyright for 2018 2018-01-03 10:03:25 -08:00
wasapi Fixed MinGW-w64 build 2018-02-24 08:23:44 -08:00
winmm Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_audio_c.h Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_audio.c Added SDL_THREAD_PRIORITY_TIME_CRITICAL 2018-04-23 22:07:56 -07:00
SDL_audiocvt.c Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_audiodev_c.h Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_audiodev.c Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_audiotypecvt.c audio: Needed to fix two more instances for Visual Studio. 2018-05-21 12:05:17 -04:00
SDL_mixer.c Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_sysaudio.h Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_wave.c Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_wave.h Updated copyright for 2018 2018-01-03 10:03:25 -08:00