[Pkg-alsa-devel] Bug#295037: alsa-base: Handle case when no sound cards are found.
tyranix
tyranix <tyranix@gmail.com>, 295037@bugs.debian.org
Sun, 13 Feb 2005 01:32:06 -0500
Package: alsa-base
Version: 1.0.8-5
Severity: minor
Tags: sid
In /etc/init.d/alsa, if no sound cards are found, the script tries to
execute commands with the variable CARDOPT="---".
The problem is that the function, echo_card_indices, does not check
for the string "--- no sound cards ---" and the sed expression trims it
down to "---". When the rest of the script tries to set various alsa
settings, you get many console beeps and usage displays.
This patch would tell the user that it did not find any supported sound
cards instead of issuing errors. I'm not that familiar with the output
of /proc/asound/cards so it may be possible to have a more
comprehensive regex:
--- /etc/init.d/alsa.old 2005-02-13 01:09:00.000000000 -0500
+++ /etc/init.d/alsa 2005-02-13 01:05:34.000000000 -0500
@@ -125,7 +125,7 @@
echo_card_indices()
{
if [ -f /proc/asound/cards ] ; then
- sed -e 's/[[:space:]].*$//' -e '/^$/d' /proc/asound/cards
+ sed -e 's/[[:space:]].*$//' -e '/^$/d'
/proc/asound/cards | grep -v "^---"
fi
}
@@ -203,9 +203,13 @@
TTSDML_RETURNSTATUS=0
case "$1" in
all)
- for CARD in $(echo_card_indices) ; do
-
try_to_set_default_mixer_levels_on_card "$CARD" ||
TTSDML_RETURNSTATUS=1
- done
+ if [ "X" = X"$(echo_card_indices)" ]; then
+ echo "Could not find any alsa sound cards"
+ else
+ for CARD in $(echo_card_indices) ; do
+
try_to_set_default_mixer_levels_on_card "$CARD" ||
TTSDML_RETURNSTATUS=1
+ done
+ fi
;;
*)
try_to_set_default_mixer_levels_on_card "$1"
|| TTSDML_RETURNSTATUS=1
@@ -253,9 +257,13 @@
TTZML_RETURNSTATUS=0
case "$1" in
all)
- for CARD in $(echo_card_indices) ; do
- try_to_zero_mixer_levels_on_card "$CARD" ||
TTZML_RETURNSTATUS=1
- done
+ if [ "X" = X"$(echo_card_indices)" ]; then
+ echo "Could not find any alsa sound cards"
+ else
+ for CARD in $(echo_card_indices) ; do
+ try_to_zero_mixer_levels_on_card
"$CARD" || TTZML_RETURNSTATUS=1
+ done
+ fi
;;
*)
try_to_zero_mixer_levels_on_card "$1" || TTZML_RETURNSTATUS=1