mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
c591429542
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. |
||
---|---|---|
.. | ||
alsa | ||
android | ||
arts | ||
coreaudio | ||
directsound | ||
disk | ||
dsp | ||
dummy | ||
emscripten | ||
esd | ||
fusionsound | ||
haiku | ||
jack | ||
nacl | ||
nas | ||
netbsd | ||
paudio | ||
psp | ||
pulseaudio | ||
qsa | ||
sndio | ||
sun | ||
wasapi | ||
winmm | ||
SDL_audio_c.h | ||
SDL_audio.c | ||
SDL_audiocvt.c | ||
SDL_audiodev_c.h | ||
SDL_audiodev.c | ||
SDL_audiotypecvt.c | ||
SDL_mixer.c | ||
SDL_sysaudio.h | ||
SDL_wave.c | ||
SDL_wave.h |