diff options
author | Simon Rettberg | 2021-10-28 16:24:38 +0200 |
---|---|---|
committer | Simon Rettberg | 2021-10-28 16:24:38 +0200 |
commit | b9c4f27bbf6f78a4fa630756650bf307b4483626 (patch) | |
tree | ce6b4d67dadbdb28a55e11e2cbe598b0396ff9e2 /core/modules/run-virt/data/opt/openslx/vmchooser | |
parent | [pulseaudio/alsa] Switch to alsa, add pactl pendant to amixer Mute (diff) | |
download | mltk-b9c4f27bbf6f78a4fa630756650bf307b4483626.tar.gz mltk-b9c4f27bbf6f78a4fa630756650bf307b4483626.tar.xz mltk-b9c4f27bbf6f78a4fa630756650bf307b4483626.zip |
[run-virt] Support PulseAudio when unmuting
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser')
-rw-r--r-- | core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc index 3afaccd5..e596b0f2 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc @@ -15,10 +15,26 @@ setup_sound() { # Read local VOL=${VOLUME_EXCEPTIONS["${HW_MANUF}//${HW_MODEL}"]} fi - + # Default to maximum volume notempty VOL || VOL="100%" - + + if ! check_dep pactl || [ "$(amixer | grep -c '^Simple mixer' )" -gt 3 ]; then + check_dep amixer && set_sound_alsa + fi + if check_dep pactl; then + set_sound_pulse + fi + writelog --quiet "Done setting up volume." +} + +set_sound_pulse() { + writelog --quiet "Setting up volume to '$VOL' via pactl..." + pactl set-sink-mute @DEFAULT_SINK@ 0 + pactl set-sink-volume @DEFAULT_SINK@ "$VOL" +} + +set_sound_alsa() { # detecting which card is to be used writelog --quiet "Detecting which sound card to use ..." local PROC="/proc/asound/cards" @@ -35,7 +51,7 @@ setup_sound() { writelog --quiet "\tNo sound card found." SOUND_CARD_INDEX=0 fi - SOUND_CARD_COUNT=$(grep -E '^[[:space:]]{0,2}[0-9]+[[:space:]]+' "${PROC}" | wc -l) + SOUND_CARD_COUNT="$( grep -E -c '^[[:space:]]{0,2}[0-9]+[[:space:]]+' "${PROC}" )" fi SOUND_CARD_INDEX="$(grep -E -o '[0-9]+' <<<$SOUND_CARD_INDEX)" @@ -79,14 +95,8 @@ setup_sound() { EOF # fix random static noise when starting vmplayer when module snd_pcsp (not pcspkr) is loaded lsmod | grep -q snd_pcsp && amixer -q -c pcsp sset Master "0%" mute - writelog --quiet "Done setting up volume." } ## MAIN ## -# Sanity checks -if ! check_dep amixer; then - writelog "'amixer' not available, sound will not work!" - error_user "Fehler" "Konnte Sound nicht initialisieren! Virtuelle Maschine wird kein Sound haben!" -else - reg_feature_handler "sound" "setup_sound" -fi +reg_feature_handler "sound" "setup_sound" +: |