Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pulseaudio real-time and high-priority scheduling modes configurable #3893

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

graph-inc
Copy link

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) and setrlimit(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:

I: [pulseaudio] main.c: setrlimit(RLIMIT_NICE, (31, 31)) failed: Operation not permitted
I: [pulseaudio] main.c: setrlimit(RLIMIT_RTPRIO, (9, 9)) failed: Operation not permitted

Disabling these two features makes pulseaudio to start up with no noticable delay. This pull request introduces two environment variables, XPRA_PULSEAUDIO_REALTIME and XPRA_PULSEAUDIO_HIGH_PRIORITY, in order to selectively disable/enable them. Both settings default to True, 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 the fs/etc/xpra/conf.d/60_server.conf.in template. This configuration file overrides the value which is computed by the get_default_pulseaudio_command(). Therefore, the XPRA_PULSEAUDIO_MEMFD environment variable which was used to selectively pass --enable-memfd=no option to pulseaudio will have no effect. Now, the pulseaudio-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.

The XPRA_PULSEAUDIO_REALTIME indicates that pulseaudio should try to
enable realtime scheduling (requires RLIMIT_RTPRIO setrlimit privilege).
The XPRA_PULSEAUDIO_HIGH_PRIORITY indicates that scheduling priority
should be increased (requires RLIMIT_NICE setrlimit privilege).

Both settings defaults to True because they are enabled by default in
the pulseaudio. However, if user does not have enough privilege, this
makes the pulseaudio to wait for one or two minutes before timing out.
@totaam totaam merged commit f18cdec into Xpra-org:master Jun 12, 2023
@totaam
Copy link
Collaborator

totaam commented Jun 12, 2023

In a testbed, it takes more than a minute to start up after printing these errors

Which distribution does this?
I have never seen this behaviour.

@graph-inc
Copy link
Author

It was tested in a Debian bullseye-slim container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants