SDL/src
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
..
atomic Updated copyright for 2018 2018-01-03 10:03:25 -08:00
audio alsa: avoid hardware parameters with an excessive number of periods. 2018-05-04 21:21:32 -04:00
core Added support for external mouse in Samsung DeX mode 2018-06-18 13:14:02 -07:00
cpuinfo cpuinfo: Added SDL_HasAVX512F(). 2018-05-21 11:35:42 -04:00
dynapi Added support for external mouse in Samsung DeX mode 2018-06-18 13:14:02 -07:00
events Added support for external mouse in Samsung DeX mode 2018-06-18 13:14:02 -07:00
file Updated copyright for 2018 2018-01-03 10:03:25 -08:00
filesystem revert the recent typecast assignment changes (see bug #4079) 2018-02-12 17:00:00 +03:00
haptic Updated copyright for 2018 2018-01-03 10:03:25 -08:00
joystick Merged in community contributed controller mappings from https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt 2018-06-12 01:04:26 -07:00
libm Fixed misleading indentation 2018-01-30 16:53:24 -08:00
loadso Updated copyright for 2018 2018-01-03 10:03:25 -08:00
main Fixed bug 4073 - Unquoted Unicode argument parsing broken on Windows due to incorrect usage of SDL_isspace() 2018-02-10 12:43:11 -08:00
power Handle NULL return from SDL_DBus_GetContext() 2018-04-23 20:24:12 -07:00
render Fixed some possible malloc(0) calls reported by static analysis. 2018-06-24 12:16:58 -04:00
stdlib make sure SDL_vsnprintf() nul terminates if it is using _vsnprintf 2018-05-10 09:02:39 +03:00
test use the 'aborts' pragma of Watcom for SDL_NORETURN functions 2018-06-13 14:45:02 +03:00
thread thread: fixed compiler warnings on non-Linux systems that use pthread. 2018-05-21 12:00:21 -04:00
timer Updated copyright for 2018 2018-01-03 10:03:25 -08:00
video x11: Normalize x11xinput2 touch x to be 1.0 at width (thanks, Zach!). 2018-06-24 13:57:22 -04:00
SDL.c Fixed bug 4034 - Don't include _DllMainCRTStartup() if SDL_STATIC_LIB is defined. 2018-02-21 09:40:47 -08:00
SDL_assert.c use the 'aborts' pragma of Watcom for SDL_NORETURN functions 2018-06-13 14:45:02 +03:00
SDL_assert_c.h Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_dataqueue.c Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_dataqueue.h Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_error.c Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_error_c.h Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_hints.c Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_internal.h Updated copyright for 2018 2018-01-03 10:03:25 -08:00
SDL_log.c Updated copyright for 2018 2018-01-03 10:03:25 -08:00