forked from ROCKNIX/distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pipewire: create 2 virtual audio devices and add user config for them
added mono and stereo virtual audio devices, this will allow handhelds such as the PowKiddy SX20 and others with just 1 mono speaker to downmix all stereo output for the single mono speaker so for games with channel specific audios, you miss out any audio while playing. This is a software only solution which allows greater flexibility to allow future manipulations of audio without touching the original HW configurations also adding the shell scripts to swap between the virtual devices later during ES operations pipewire: make virtual audio optional only for RK3326 and RK3566 platforms Signed-off-by: Paul Reioux <[email protected]> pipewire: enable virtual audio drivers for all rocknix devices Signed-off-by: Paul Reioux <[email protected]>
- Loading branch information
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
context.modules = [ | ||
{ name = libpipewire-module-loopback | ||
args = { | ||
node.description = "Stereo Playback Device" | ||
capture.props = { | ||
node.name = "stereo_output" | ||
media.class = "Audio/Sink" | ||
audio.position = [ FL FR ] | ||
} | ||
playback.props = { | ||
node.name = "playback.stereo_output" | ||
audio.position = [ FL FR ] | ||
node.passive = true | ||
} | ||
} | ||
} | ||
{ name = libpipewire-module-loopback | ||
args = { | ||
node.description = "Mono Playback Device" | ||
capture.props = { | ||
node.name = "mono_output" | ||
media.class = "Audio/Sink" | ||
audio.position = [ MONO ] | ||
} | ||
playback.props = { | ||
node.name = "playback.mono_output" | ||
audio.position = [ MONO ] | ||
node.passive = true | ||
} | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
#load some built-in useful functions | ||
. /etc/profile.d/001-functions | ||
|
||
AUDIO_V_DEVICE_SETTING_KEY="audio.v-driver" | ||
|
||
get_current_driver() { | ||
CONFDRIVER=$(get_setting ${AUDIO_V_DEVICE_SETTING_KEY}) | ||
|
||
if [ -z ${CONFDRIVER} ]; then | ||
CONFDRIVER="stereo" #default to stereo | ||
set_setting ${AUDIO_V_DEVICE_SETTING_KEY} ${CONFDIRVER} | ||
fi | ||
} | ||
|
||
load_driver() { | ||
DRIVER_TO_LOAD=$1 | ||
case ${DRIVER_TO_LOAD} in | ||
"stereo") | ||
number=$(wpctl status | grep -m 1 "Stereo Playback Device" | grep -Eo '[0-9]+' | awk 'NR==1{print; exit}') | ||
;; | ||
"mono") | ||
number=$(wpctl status | grep -m 1 "Mono Playback Device" | grep -Eo '[0-9]+' | awk 'NR==1{print; exit}') | ||
;; | ||
*) | ||
exit 3 | ||
;; | ||
esac | ||
|
||
# Check if the number is extracted successfully | ||
if [ -n "$number" ]; then | ||
# Set the default with the extracted number | ||
wpctl set-default "$number" | ||
echo "Default set to $number" | ||
else | ||
echo "Error: Unable to extract number from command output." | ||
fi | ||
} | ||
|
||
case "$1" in | ||
"--options") | ||
echo "stereo mono" | ||
;; | ||
"--start") | ||
get_current_driver | ||
load_driver ${CONFDRIVER} | ||
;; | ||
"stereo" | "mono") | ||
set_setting ${AUDIO_V_DEVICE_SETTING_KEY} $1 | ||
get_current_driver | ||
echo ${CONFDRIVER} | ||
load_driver ${CONFDRIVER} | ||
;; | ||
"") | ||
get_current_driver | ||
echo ${CONFDRIVER} | ||
;; | ||
*) | ||
echo "Unexpected parameter $1" >&2 | ||
echo "Usage:" >&2 | ||
echo " List available drivers: $0 --options" >&2 | ||
echo " Load configured driver and set libs: $0 --start" >&2 | ||
echo " Get current driver: $0" >&2 | ||
echo " Configure driver to load immediately: $0 <stereo|mono>" >&2 | ||
exit 1 | ||
;; | ||
esac |