alvr-org / ALVR

Stream VR games from your PC to your headset via Wi-Fi
MIT License
5.52k stars 488 forks source link

Add pipewire troubleshooting notes #2236

Open The-personified-devil opened 4 months ago

The-personified-devil commented 4 months ago

Issue because blocked on #2233, but we should mention that A) Pipewire error: Creation failed likely means pipewire isn't setup as the audio server and B) no audio but no error means that the device just wasn't selected in the audio settings (potentially only as a stopgap for a default button, but idk if that's feasible and configuring the audio device is an operation that imo is kinda to be expected as a user, but if you didn't think of it the troubleshooting page could just give you a heads up)

Meister1593 commented 4 months ago

For default audio we probably can use wireplumber, though some setups use pipewire-media-session instead (not sure how to handle that)

The-personified-devil commented 4 months ago

From what I can tell session managers also only set pipewire properties and other applications like easyeffects manage to place themselves as the default sink with just pw, so it should be possible in just pipewire and we should definitely look into that then

Meister1593 commented 4 months ago

Good news: i found where are default configured audio devices are. It's found on one of the PipeWire:Interface:Metadata under metadata sections as default.configured.audio.sink, default.configured.audio.source Bad news: to get that without wireplumber, we literally have to do it all manually, and wireplumber is doing exactly the same thing IMO we should look into using wireplumber instead, it seems like double work to do the same thing. Maybe note users that they should probably switch to wireplumber (unless user has specific scripts on pipewire-media-session, wireplumber is a drop in replacement)

Otherwise it looks like a huge chunk of pretty unreadable code to parse bunch of properties just to get default device, and then set it through pipewire context. Most likely even more than current code for pipewire.

The-personified-devil commented 4 months ago

Or rather it seems that wireplumber sets the default device based on information inside of pipewire. The priority.session key is also what you would use with wireplumber to configure priorities. So we could try using that. The second option would be to get the default device and move all their streams to us, that's how easyeffects does it, but I don't think that's a good idea.

The-personified-devil commented 4 months ago

Update: I tested that key and it seems to only work if you haven't manually set a default device and pipewire is just figuring it out automatically. Now it would be epic if users had clearly defined priorities so that they just need to connect devices and it automatically picks the right one, but that isn't the case and people set default devices, so this won't work. Bummer.

The-personified-devil commented 4 months ago

I have two proposals instead: A) We use wireplumber and make it soft-fail to a notice that the user has to set the default device themselves or B) Check if no streams are connected to us and warn the user that they might have to set alvr as default if they haven't already

also if we do something to set defaults, it should be done every time the device appears to ensure reliability, so a toggle to the audio settings to set the device as default automatically

fpemud commented 3 months ago

Wireplumber includes some lua scripts that can automatically modify sound route / default sink as needed. For example, when a bluetooth headset is connected, default sink is changed from the speaker to the headset, audio stream is rerouted accordingly. The speaker consistently remains as the default sink throughout the whole process (if I remember correctly). However, I believe wp lua scripts do not include the logic to set ALVR as the default sink and change sound route when ALVR is started (or when the HMD is connected?). A dedicated lua script should be installed to solve the "default audio" problem, like installing an udev rule file. I am not familiar with writing wp lua scripts, but wireplumber is designed in this way. In other words, only "pipewire session manager" should be responsible for changing sound routes, applications (except for special applications like easyeffects) should never touch the sound route. For pipewire-media-session, it should also have similar mechanism.

The-personified-devil commented 3 months ago

We don't really want to support more than wireplumber, since pw-media-session is effectively deprecated. And we can't really ship wp scripts because our preferred distribution route is the launcher or mobile (as in shouldn't be installed system wide) tarballs. We could create a script and ship it for the distros that actually package alvr (very few ones).

I much rather think we should instead focus on actually easily providing the user with feedback on how to act, i.e.:

B) Check if no streams are connected to us and warn the user that they might have to set alvr as default if they haven't already

0chroma commented 2 months ago

btw, to get pipewire working in the flatpak install instructions I needed to add xdg-run/pipewire-0 permissions via flatseal:

Screenshot from 2024-08-29 17-07-01

terminal equivalent should be flatpak override --user --filesystem="xdg-run/pipewire-0" com.valvesoftware.Steam (have not tested this though)