ALVR icon indicating copy to clipboard operation
ALVR copied to clipboard

Linux pipewire integration (Audio + Microphone)

Open Meister1593 opened this issue 1 year ago • 14 comments

This is not done by any means, just put up for anyone to see how things are progressing So far: main flow (pipewire source, getting data from one place to another) is kinda done, but i've yet to determine why only thing i get is pops into mic, it might be a multiple issues at once (buffer overload + trying to push all at once) Other issues are listed in TODO's

Meister1593 avatar Feb 04 '24 20:02 Meister1593

I haven't reviewed completely. But linux specific code should go in crates/audio/src/linux.rs

zmerp avatar Feb 05 '24 02:02 zmerp

I haven't reviewed completely. But linux specific code should go in crates/audio/src/linux.rs

Please don't review it completely yet, its just in barely compilable state, not ready for any serious review of the code itself.

Meister1593 avatar Feb 05 '24 05:02 Meister1593

Cool! Any way to help?

guysoft avatar Feb 26 '24 18:02 guysoft

Cool! Any way to help?

no not really unless you wanna pull a night of just reading documentation on oboe(not the rust crate but the google software one) oh and you somehow figure out what we're doing wrong so you have to know Rust too

Vixea avatar Feb 26 '24 22:02 Vixea

Current progress: Both audio sink and microphone source are being created and working correctly! What's left to do: Refactor platform-specific code, overalll cleanup code and make UI edits to allow for native pipewire, make it default with fallback to cpal in case pipewire is missing or outdated (this specifically - unlikely scenario? code needs at least 0.3.49 pipewire).

Meister1593 avatar Jun 05 '24 11:06 Meister1593

I would say that the pipewire audio code can replace cpal for linux.

zmerp avatar Jun 05 '24 20:06 zmerp

I think a fair amount of people still run pulseaudio and for them audio would not work at all. So either we make pipewire a hard requirement or we keep the cpal code around for the time being.

The-personified-devil avatar Jun 05 '24 20:06 The-personified-devil

I've considered removing cpal, but i know that linux mint is still on pulse

That said, they won't have microphone and they can technically switch to pipewire (and they should really)

I'm 50/50 about this, but inclined to removing cpal from linux and going pipewire all the way, and point people to install pipewire.

Meister1593 avatar Jun 05 '24 20:06 Meister1593

I looked at it and basically all big distros (arch, debian, ubuntu, fedora, centos) have been shipping pipewire as default for at least a year, and every other sane distro has support for it. Even Mint will ship it as default in the upcoming release. So I think forcing pipewire should be the thing.

The-personified-devil avatar Jun 05 '24 21:06 The-personified-devil

I looked at it and basically all big distros (arch, debian, ubuntu, fedora, centos) have been shipping pipewire as default for at least a year, and every other sane distro has support for it. Even Mint will ship it as default in the upcoming release. So I think forcing pipewire should be the thing.

Then i think that settles it, i would remove cpal from linux completely Would need to adjust ui with that as well, probably gonna make conditionals for audio section to remove parts of it on linux

Meister1593 avatar Jun 05 '24 21:06 Meister1593

I've considered removing cpal, but i know that linux mint is still on pulse

Linux Mint will be moving to PipeWire from the next release - https://blog.linuxmint.com/?p=4660. Obviously there will still be those on earlier versions of LM that are still on PulseAudio though, although maybe it'll be the nudge those users need to upgrade (or install PipeWire separately). :)

infidelus avatar Jun 06 '24 09:06 infidelus

In current state: Creates sink (ALVR Audio) and microphone (ALVR Microphone), they are working as a regular device (no different to others) image Replaced audio presets to just toggles image Advanced audio will be changed to hide older cpal device list for linux (not in this PR)

Only thing left to do is remove on connect script from setup guide, maybe even make a migration so that it will be removed to not interfere with pipewire from this PR

Opened PR for review, for suggestions, and will use it for the time being to find any inconsistencies or issues if there will be any

Meister1593 avatar Jun 09 '24 17:06 Meister1593

~~trying this PR, i cannot get the microphone (im using a quest 2) to work (i couldnt get it to work on master branch either), i built both the client and server from source on this branch, and with reset settings, with no pipewire connection scripts, all the audio stuff enabled with default settings~~ ~~i see the audio devices like this post, and pc -> quest audio works fine, but i cannot get quest -> pc mic working, theres just no audio on the device, is there something specific i have to do? i did give the app mic permissions~~

~~im using pipewire on latest arch linux as of writing, with wireplumber~~

EDIT: i seem to have a hardware/software fault in my headset making the microphone not function at all (even with a USB mic), so disregard the above

Beyley avatar Jun 17 '24 09:06 Beyley

btw remaining issues causing CI failure are:

  • macos is lacking an impl for AudioDevice, so that needs a stub
  • linux CI is lacking the pipewire package, CI needs to install more pkgs
  • windows is misc rust errors

The-personified-devil avatar Jun 22 '24 01:06 The-personified-devil

Apart from the noted changes this lgmt, but I'm not fit to review rust code style

The-personified-devil avatar Jul 03 '24 20:07 The-personified-devil