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

audio: Prefer Pipewire over Pulseaudio (take 2) #9473

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

Kontrabant
Copy link
Contributor

If SDL is configured with both Pipewire and Pulseaudio support, this adds a preferred Pipewire bootstrap entry that uses DBus to query if the pipewire-pulse service exists and is in the "running" state. If it is, then it is certain that Pipewire is being used instead of Pulseaudio as the preferred system mixer and will be preferred over Pulseaudio. If DBus support is not enabled or Systemd is not being used on the underlying system, this check will simply fail and the standard driver order will be tested as before.

While still not 100% flawless, it is currently the best method for detecting if Pipewire is the preferred mixer for the system, as other possibilities have drawbacks:

  • Simply checking for sinks/sources won't work, as Pipewire can still be used to mix audio and lists sinks/sources, even if the system is also running the real Pulseaudio server.
  • Using pactl to dump the info string and look for "pipewire" requires that the user installed the Pulseaudio utilities, which typically aren't installed by default, and that their behavior is never altered.

Closes #8788

cc @flibitijibibo @icculus

…is running

Use DBus to query Systemd to check if the pipewire-pulse service is in the "running" state. If it is, then it is certain that Pipewire is being used instead of Pulseaudio as the preferred system mixer.

If DBus support is not enabled or Systemd is not being used on the underlying system, this check will simply fail and the standard driver order will be tested.
Copy link
Collaborator

@flibitijibibo flibitijibibo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me - I guess we should sync this with the Wayland preference change to make sure the bootstrap logic all matches?

@icculus
Copy link
Collaborator

icculus commented Apr 7, 2024

Yeah, this is clever. I haven't looked at what the Wayland stuff does that we could sync up here, but take a look at that and see if it's worth it before we merge this.

@flibitijibibo
Copy link
Collaborator

Posted in the Wayland thread, aside from that this should be good to go (IMO).

@icculus
Copy link
Collaborator

icculus commented Apr 11, 2024

Yeah, I think the Wayland stuff should match this.

Okay, last call before I pull the trigger on merging this, then!

@icculus icculus merged commit 60f2618 into libsdl-org:main Apr 12, 2024
35 checks passed
@Kontrabant Kontrabant deleted the SDL3_prefer_pipewire branch April 12, 2024 00:46
@swick
Copy link

swick commented Apr 15, 2024

This is broken in a lot of environments, including flatpak which is arguably the most common environment SDL will run in.

The name of services is not stable, access to the session bus is restricted. This change is overall just a really bad idea and SDL_DBus_QuerySystemdUnitRunning should be thrown away.

Checking for the pipewire socket should be much more robust and give you the same behavior. Usually if the pipewire socket exists, the pulse socket also comes from pipewire.

@slouken
Copy link
Collaborator

slouken commented Apr 15, 2024

@swick, can you open an issue on this for tracking?

@swick
Copy link

swick commented Apr 15, 2024

#9543

@slouken
Copy link
Collaborator

slouken commented Apr 15, 2024

Thanks!

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.

SDL 3 Loopwave : Audio no output and code freeze on USB Headphone via PulseAudio driver
5 participants