Add framework for implementing Linux AudioManager

Source outputs must all be moved to new default source.
Reference topic
https://askubuntu.com/a/72076

* Adds microphone controls on Linux via PulseAudio (PA) for several
points in
https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings/issues/43.

It can not be overstated how unsuited the public AudioManager API is for
using the PA API.

It can also not be overstated how undocumented and horrible the PA API
is. The PA way of doing audio is very unlike the Windows way of doing
audio, which the AudioManager is heavily influenced by.

Since I don't have a Linux machine I have not been able to personally
test this. https://github.com/feilen/ has graciously helped with
testing.

PulseAudio is very undocumented and not very widely used for what we
need outside of official utilities. As such there's most likely a better
way of doing things than I've done.
Additional information can be found at
https://github.com/username223/pulseaudio-device-changing.

The "complex" PA API is asynchronous. Since our current AudioManager is
running synchronously and would not work asynchronously (functions are
expected to return valid data on function return) it is necessary to
massage the PA API until it runs synchronously.

This is done with a general workflow of

1. Register a callback function (`pa_context_get_source_info_list()`,
        for example).
2. Run the PA loop through `customPulseLoop()`. This will trigger
any registered callbacks. Sometimes a `void*` is passed through the
callback that can be used for custom data. `successCallback()` uses
this to set the success variable.
3. Run the callback function and do required work.
4. Return to original function, do work or return values.

It is not possible to run a `customPulseLoop()` inside of an already
running loop (inside a callback), as this will lead to a PA assert
error on runtime.
This commit is contained in:
Vasily
2020-04-08 22:44:12 +02:00
committed by username223
parent 9225956e8a
commit bb30a7c041
8 changed files with 924 additions and 22 deletions
+17 -4
View File
@@ -16,6 +16,7 @@
* [qtchooser and versions](#qtchooser-and-versions)
* [X11](#x11)
* [DBUS](#dbus)
* [PulseAudio](#pulseaudio)
* [SteamVR](#steamvr)
* [clang-tidy and bear](#clang-tidy-and-bear)
* [TL;DRs](#tldrs)
@@ -188,6 +189,12 @@ DBUS is needed for controlling media players from VR.
This feature and dependency can be disabled during compilation.
## PulseAudio
PulseAudio is needed for controlling audio devices through the Audio tab.
This feature and dependency can be disabled during compilation.
## SteamVR
On a completely fresh Ubuntu install the program also requires the following libraries to run.
@@ -226,7 +233,7 @@ sudo apt-get -y install build-essential libgl1-mesa-dev
# Install Qt
sudo apt-get -y install qt512-meta-full qtchooser
# Install additional features
sudo apt-get -y install libx11-dev libxt-dev libxtst-dev
sudo apt-get -y install libx11-dev libxt-dev libxtst-dev libpulse-dev
# Install necessary SteamVR libraries
sudo apt-get -y install libsdl2-dev libvulkan-dev
# Set up qtchooser
@@ -253,7 +260,7 @@ sudo apt-get -y install build-essential libgl1-mesa-dev
# Install Qt
sudo apt-get -y install qt512-meta-full qtchooser
# Install additional features
sudo apt-get -y install libx11-dev libxt-dev libxtst-dev
sudo apt-get -y install libx11-dev libxt-dev libxtst-dev libpulse-dev
# Install necessary SteamVR libraries
sudo apt-get -y install libsdl2-dev libvulkan-dev
# Set up qtchooser
@@ -277,7 +284,7 @@ sudo apt-get -y install build-essential libgl1-mesa-dev
# Install Qt
sudo apt-get -y install qt5-default qtmultimedia5-dev libqt5multimediawidgets5 libqt5multimedia5-plugins libqt5multimedia5 qml-module-qtquick-extras qml-module-qtquick-controls2 qml-module-qtquick-dialogs qtdeclarative5-dev qtchooser
# Install additional features
sudo apt-get -y install libx11-dev libxt-dev libxtst-dev
sudo apt-get -y install libx11-dev libxt-dev libxtst-dev libpulse-dev
# Install necessary SteamVR libraries
sudo apt-get -y install libsdl2-dev libvulkan-dev
# Set up qtchooser
@@ -300,7 +307,7 @@ sudo pacman --noconfirm -S base-devel mesa libudev0-shim
# Install Qt
sudo pacman --noconfirm -S qt5-declarative qt5-multimedia
# Install additional features
sudo pacman --noconfirm -S xorg-server dbus
sudo pacman --noconfirm -S xorg-server dbus libpulse-dev
# Compile
qmake
make -j2
@@ -334,6 +341,7 @@ The following values can be appended to the `CONFIG` internal variable in order
| ----- | ------- |
| `noX11` | Disables X11 specific features (VR to keyboard input). |
| `noDBUS` | Disables DBUS specific features (control media players). |
| `noPulse` | Disables PulseAudio specific features (change audio devices). |
| `debugSymbolsAndLogs` | Enables debug symbols and debug logging calls (while still having release optimizations). |
The values are case sensitive.
@@ -348,6 +356,11 @@ If you want to disable both X11 and DBUS features you would type
qmake CONFIG+=noX11 CONFIG+=noDBUS
```
If you want to disable X11, DBUS and PulseAudio features you would type
```bash
qmake CONFIG+=noX11 CONFIG+=noDBUS CONFIG+=noPulse
```
The location for `make install` can be configured in the `qmake` step.
This is done by setting the `PREFIX` variable.
```bash