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

Linux Audio Streaming #673

Closed
ckiee opened this issue May 20, 2021 · 18 comments · Fixed by #1973
Closed

Linux Audio Streaming #673

ckiee opened this issue May 20, 2021 · 18 comments · Fixed by #1973
Labels
enhancement New feature or request linux This seems to be linux-specific

Comments

@ckiee
Copy link
Member

ckiee commented May 20, 2021

Even though no one tried to make any changes for audio streaming on Linux, with the power of cool abstractions, it already works: #269 (comment)!

Microphone streaming (i.e. headset -> PC) does not currently work.

@ckiee ckiee added enhancement New feature or request linux This seems to be linux-specific labels May 20, 2021
@m00nwtchr
Copy link
Member

m00nwtchr commented May 20, 2021

Here's the pw-cli output, again: https://gist.github.com/lmarianski/46dca0e23884868fc6b73f6687c64f9d
:p

@Killrmemz
Copy link
Contributor

For me, Audio streaming (running PipeWire for my system) is working, but not properly.
Some devices in the list crash ALVR or SteamVR in various ways, and others stream one of the microphones on the computer, resulting in a feedback loop between the PC microphone and my quest's speakers. I cannot get it to stream system audio at all.

@m00nwtchr
Copy link
Member

m00nwtchr commented Jul 18, 2021

@yackaro yea some options from the list crash for me too, try installing pipewire-jack(or whatever the actual package name is on your distro) and select the jack device on the list

@Killrmemz
Copy link
Contributor

@lmarianski already set it up with that, started the JACK server and it's still not working. all that JACK is able to pick up is my laptop microphone, which results in the same feedback loop as ever.

@mittorn
Copy link

mittorn commented Jul 28, 2021

Microphone streaming works perfectly with jackd server + alsa jack plugin.
I added 3 alsa-jack devices in asoundrc, one is default, and two for ALVR with fixed names, with plug devices for each one. cal seems to require non-empty hint on device to show it in list
first device selected to capture audio, second as microphone in and default as microphone out.
And simple rule in qjackctl router which connects all outputs to capture in and all inputs to microphone in. The only issue that i hear real PC microphone in ALVR client (i do not know how to make rule that disconnects alvr capture from system capture device), but it may be fixed by calling jack_disconnect after every ALVR launch
I think, it should be possible to make same configuration with alsa + 2 loopback devices without jack server

@mittorn
Copy link

mittorn commented Jul 28, 2021

Also, i removed jack library from steam runtime, because it was incompatible with system jack server

@Kirottu
Copy link
Collaborator

Kirottu commented Jan 31, 2022

For me using pipewire-media-session this does not work at all, it only crashes with At alvr/audio/src/lib.rs:382: A backend-specific error has occurred: ALSA function 'snd_pcm_hw_params' failed with error 'EIO: I/O error'. With wireplumber I only hear static and many of my other utilities break.

Edit:
I specified my headphones' ALSA device and it did not error out, but I heard nothing.

@Kirottu
Copy link
Collaborator

Kirottu commented Feb 7, 2022

Update on my discoveries:

Apparently the jack option tried to record audio from my headset microphone, which was disabled. This caused the I/O errors and re-enabling the microphone input allowed for ALVR to start. The static was apparently simply due to the microphone being really bad. After ALVR had started I could use helvum to re-route the audio to properly stream audio to the headset.

@LuNeder
Copy link

LuNeder commented Jun 30, 2022

Update on my discoveries:

Apparently the jack option tried to record audio from my headset microphone, which was disabled. This caused the I/O errors and re-enabling the microphone input allowed for ALVR to start. The static was apparently simply due to the microphone being really bad. After ALVR had started I could use helvum to re-route the audio to properly stream audio to the headset.

Did you find a way to automatically reroute the audio?
Choosing "pipewire" on ALVR and then using Helvum to manually reroute audio to "pipewire alsa" makes it work, but I have to manually reroute the audio for every single app I open, every single time I open them.

@mittorn
Copy link

mittorn commented Jul 6, 2022

JACK has many routing utilities, it might help with pipewire

@DocMAX
Copy link

DocMAX commented Oct 20, 2023

On arch i installed the pipewire-jack package. But i dont see any jack device in Helvum?!?

@sol8712
Copy link

sol8712 commented Oct 24, 2023

Update on my discoveries:
Apparently the jack option tried to record audio from my headset microphone, which was disabled. This caused the I/O errors and re-enabling the microphone input allowed for ALVR to start. The static was apparently simply due to the microphone being really bad. After ALVR had started I could use helvum to re-route the audio to properly stream audio to the headset.

Did you find a way to automatically reroute the audio? Choosing "pipewire" on ALVR and then using Helvum to manually reroute audio to "pipewire alsa" makes it work, but I have to manually reroute the audio for every single app I open, every single time I open them.

Try qpwgraph, its like a more feature complete version of Helvum but can save your setups and its probably in your package manager already.
Auto start minimized on boot with your saved patchbay see: qpwgraph -h

You could even route it to easy effects for mic effects.

@GrigoriyPeters
Copy link

Hi everybody! I made a workaround for this issue:
https://gist.github.com/GrigoriyPeters/5f2e08ad534f788b677c5fb671ac8ebd

This is a workaround for a system with pipewire as the primary audio server, which has been tested on Archlinux and Pico 4 as a headset. What it does:

Creates a virtual sink named MySink, that you can choose as the default in your GUI
Checks in a loop every second to see if alsa_capture.vrserver headset speakers are available
Removes everything from this server (alsa_capture.vrserver)
Connects MySink to alsa_capture.vrserver

@Meister1593
Copy link
Collaborator

Meister1593 commented Dec 3, 2023

Didn't know about this issue, but I guess this can be posted
Alvr kinda already had it in docs, anyway:
https://github.com/alvr-org/ALVR/wiki/Installation-guide#automatic-audio--microphone-setup
Its supposed to be portable, no additional stuff aside from pipewire in settings and setting this script as on connect/on disconnect required, and it would move playback/recording to required sinks.

@GrigoriyPeters
Copy link

Didn't know about this issue, but I guess this can be posted Alvr kinda already had it in docs, anyway: https://github.com/alvr-org/ALVR/wiki/Installation-guide#automatic-audio--microphone-setup Its supposed to be portable, no additional stuff aside from pipewire in settings and setting this script as on connect/on disconnect required, and it would move playback/recording to required sinks.

Welp. It looks like the thing I did. But mine loops every second and automatically connects the sound to the headset if it is connected, and connects back to the default sink otherwise.
My Pico 4 disconnects after about 10 seconds of inactivity (proximity sensor) and it works for me.

@Meister1593
Copy link
Collaborator

Meister1593 commented Dec 3, 2023

That script doesn't loop, it's passive and doesn't need any background activity.
It essentially does what you would do in pavucontrol when you change playback/recording sinks in first tab, but programmatically.
Works fine with pico 4, or any other headset

@GrigoriyPeters
Copy link

That script doesn't loop, it's passive and doesn't need any background activity. It essentially does what you would do in pavucontrol when you change playback/recording sinks in first tab, but programmatically. Works fine with pico 4, or any other headset

Thanks. I've tested this script and it works well.
Perhaps it should come by default.

@Meister1593
Copy link
Collaborator

Meister1593 commented Dec 3, 2023

That script doesn't loop, it's passive and doesn't need any background activity. It essentially does what you would do in pavucontrol when you change playback/recording sinks in first tab, but programmatically. Works fine with pico 4, or any other headset

Thanks. I've tested this script and it works well. Perhaps it should come by default.

Technically nightly already has automatic script setup and set (in first time setup screen), but (proper) native pipewire without cpal through alsa, without scripts is currently in active development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request linux This seems to be linux-specific
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants