Make pulseaudio real-time and high-priority scheduling modes configurable #3893
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The pulseaudio tries to use real-time scheduling as the first option and increases its scheduling priority by decreasing its nice level as the second option in order to make sure that it always gets enough CPU time for refillment of the playback buffers. However, these two options require extra privileges in Linux to call the
setrlimit(RLIMIT_RTPRIO, rlim)
andsetrlimit(RLIMIT_NICE, rlim)
respectively which may be unavailable for normal users. For users which cannot call these rlimits, the pulseaudio will try for a while and so does not start quickly. In a testbed, it takes more than a minute to start up after printing these errors:Disabling these two features makes pulseaudio to start up with no noticable delay. This pull request introduces two environment variables,
XPRA_PULSEAUDIO_REALTIME
andXPRA_PULSEAUDIO_HIGH_PRIORITY
, in order to selectively disable/enable them. Both settings default toTrue
, keeping them enabled like now, so there will be no visible changes by default.This pull request also fixes a packaging issue. By default, the
pulseaudio-command
setting is filled based on thefs/etc/xpra/conf.d/60_server.conf.in
template. This configuration file overrides the value which is computed by theget_default_pulseaudio_command()
. Therefore, theXPRA_PULSEAUDIO_MEMFD
environment variable which was used to selectively pass--enable-memfd=no
option to pulseaudio will have no effect. Now, thepulseaudio-command
setting is filled as a commented line in that config file, so environment variables are kept functional while users may disable them by uncommenting that setting too.