Add audio switching for discrete internal ALSA devices

This commit is contained in:
Simon Long 2020-01-20 11:40:07 +00:00
parent 5a888f7e35
commit 629699ff9b
2 changed files with 71 additions and 10 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
raspi-config (20200120) buster; urgency=medium
* Add audio switching for discrete internal ALSA devices
-- Simon Long <simon@raspberrypi.org> Mon, 20 Jan 2020 11:38:37 +0000
raspi-config (20200117) buster; urgency=medium
* Add proxy configuration

View File

@ -1573,6 +1573,7 @@ do_update() {
}
do_audio() {
if aplay -l | grep -q "bcm2835 ALSA"; then
if [ "$INTERACTIVE" = True ]; then
AUDIO_OUT=$(whiptail --menu "Choose the audio output" 20 60 10 \
"0" "Auto" \
@ -1585,6 +1586,60 @@ do_audio() {
if [ $? -eq 0 ]; then
amixer cset numid=3 "$AUDIO_OUT"
fi
else
ASPATH=$(getent passwd $USER | cut -d : -f 6)/.asoundrc
if [ "$INTERACTIVE" = True ]; then
CARD0=$(aplay -l | grep bcm2835 | grep "card 0" | cut -d [ -f 3 | cut -d ] -f 1 | cut -d ' ' -f 2-)
CARD1=$(aplay -l | grep bcm2835 | grep "card 1" | cut -d [ -f 3 | cut -d ] -f 1 | cut -d ' ' -f 2-)
CARD2=$(aplay -l | grep bcm2835 | grep "card 2" | cut -d [ -f 3 | cut -d ] -f 1 | cut -d ' ' -f 2-)
if ! [ -z "$CARD2" ]; then
AUDIO_OUT=$(whiptail --menu "Choose the audio output" 20 60 10 \
"0" "$CARD0" \
"1" "$CARD1" \
"2" "$CARD2" \
3>&1 1>&2 2>&3)
elif ! [ -z "$CARD1" ]; then
AUDIO_OUT=$(whiptail --menu "Choose the audio output" 20 60 10 \
"0" "$CARD0" \
"1" "$CARD1" \
3>&1 1>&2 2>&3)
elif ! [ -z "$CARD0" ]; then
AUDIO_OUT=$(whiptail --menu "Choose the audio output" 20 60 10 \
"0" "$CARD0" \
3>&1 1>&2 2>&3)
else
whiptail --msgbox "No internal audio devices found" 20 60 1
false
fi
else
AUDIO_OUT=$1
fi
if [ $? -eq 0 ]; then
cat << EOF > $ASPATH
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "output"
}
capture.pcm {
type plug
slave.pcm "input"
}
}
pcm.output {
type hw
card $AUDIO_OUT
}
ctl.!default {
type hw
card $AUDIO_OUT
}
EOF
fi
fi
}
do_resolution() {