refactor: clean up sound_card variables

This commit is contained in:
Martin Wimpress 2024-05-12 23:45:46 +01:00 committed by Martin Wimpress
parent 2d4157f4c1
commit 06a18b0045
1 changed files with 12 additions and 17 deletions

View File

@ -494,13 +494,13 @@ function vm_boot() {
if [ "${guest_os}" == "freedos" ] ; then if [ "${guest_os}" == "freedos" ] ; then
# fix for #382 # fix for #382
SMM="on" SMM="on"
SOUND_CARD="sb16" sound_card="sb16"
fi fi
if [[ "${guest_os}" == *"solaris" ]]; then if [[ "${guest_os}" == *"solaris" ]]; then
MACHINE_TYPE="pc" MACHINE_TYPE="pc"
USB_CONTROLLER="xhci" USB_CONTROLLER="xhci"
SOUND_CARD="ac97" sound_card="ac97"
fi fi
if [ -z "${disk_size}" ]; then if [ -z "${disk_size}" ]; then
@ -813,14 +813,14 @@ function vm_boot() {
VIDEO="${VGA} ${VIDEO} ${FULLSCREEN}" VIDEO="${VGA} ${VIDEO} ${FULLSCREEN}"
# Build the sound hardware configuration # Build the sound hardware configuration
if [ "${SOUND_CARD}" == "intel-hda" ]; then if [ "${sound_card}" == "intel-hda" ]; then
SOUND="-device intel-hda -device hda-duplex,audiodev=audio0" SOUND="-device intel-hda -device hda-duplex,audiodev=audio0"
elif [ "${SOUND_CARD}" == "ac97" ] || [ "${SOUND_CARD}" == "es1370" ] || [ "${SOUND_CARD}" == "sb16" ]; then elif [ "${sound_card}" == "ac97" ] || [ "${sound_card}" == "es1370" ] || [ "${sound_card}" == "sb16" ]; then
SOUND="-device ${SOUND_CARD},audiodev=audio0" SOUND="-device ${sound_card},audiodev=audio0"
elif [ "${SOUND_CARD}" == "none" ]; then elif [ "${sound_card}" == "none" ]; then
SOUND="" SOUND=""
fi fi
echo " - Sound: ${SOUND_CARD}" echo " - Sound: ${sound_card}"
# Set the hostname of the VM # Set the hostname of the VM
local NET="user,hostname=${VMNAME}" local NET="user,hostname=${VMNAME}"
@ -1438,8 +1438,8 @@ function display_param_check() {
} }
function sound_card_param_check() { function sound_card_param_check() {
if [ "${SOUND_CARD}" != "intel-hda" ] && [ "${SOUND_CARD}" != "ac97" ] && [ "${SOUND_CARD}" != "es1370" ] && [ "${SOUND_CARD}" != "sb16" ] && [ "${SOUND_CARD}" != "none" ]; then if [ "${sound_card}" != "intel-hda" ] && [ "${sound_card}" != "ac97" ] && [ "${sound_card}" != "es1370" ] && [ "${sound_card}" != "sb16" ] && [ "${sound_card}" != "none" ]; then
echo "ERROR! Requested sound card '${SOUND_CARD}' is not recognised." echo "ERROR! Requested sound card '${sound_card}' is not recognised."
exit 1 exit 1
fi fi
} }
@ -1568,7 +1568,7 @@ keyboard_layout="en-us"
# options: ps2, usb, tablet, virtio # options: ps2, usb, tablet, virtio
mouse="${mouse:-tablet}" mouse="${mouse:-tablet}"
# options: intel-hda, ac97, es1370, sb16, none # options: intel-hda, ac97, es1370, sb16, none
sound_card="intel-hda" sound_card="${sound_card:-intel-hda}"
ACCESS="" ACCESS=""
BRAILLE="" BRAILLE=""
@ -1605,7 +1605,6 @@ SERIAL_TELNET_HOST=""
KEYBOARD="" KEYBOARD=""
KEYBOARD_LAYOUT="" KEYBOARD_LAYOUT=""
USB_CONTROLLER="" USB_CONTROLLER=""
SOUND_CARD=""
# shellcheck disable=SC2155 # shellcheck disable=SC2155
readonly LAUNCHER=$(basename "${0}") readonly LAUNCHER=$(basename "${0}")
@ -1760,9 +1759,8 @@ else
shift; shift;
shift;; shift;;
-sound-card|--sound-card) -sound-card|--sound-card)
SOUND_CARD="${2}" sound_card="${2}"
shift; shift 2;;
shift;;
-version|--version) -version|--version)
echo "${VERSION}" echo "${VERSION}"
exit;; exit;;
@ -1874,9 +1872,6 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then
exit 1 exit 1
fi fi
if [ -z "${SOUND_CARD}" ]; then
SOUND_CARD="${sound_card}"
fi
sound_card_param_check sound_card_param_check
# Check if vm is already run # Check if vm is already run