Skip to content

Commit 2024c5e

Browse files
committed
lib.sh: Reset ALSA settings at set_alsa()
Reset ALSA settings with `alsactl init` and `alsactl restore` at `set_alsa()` before it calls `set_alsa_settings` which runs HW model-specific configuration scripts. This way a test case can expect that the `set_alsa` call will apply the DUT's default ALSA settings as the baseline configuration to avoid side-effects possible after the previous tests execution (either passed, or failed) as well as other unexpected changes. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
1 parent d861894 commit 2024c5e

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

case-lib/lib.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,19 +1236,36 @@ reset_sof_volume()
12361236
get_sof_controls "0" | sed -e "s/^.*'\(.*\)'.*/\1/" |grep -E 'PGA|gain' |
12371237
while read -r mixer_name
12381238
do
1239-
dlogi "Reset volume to ${level_db} on ${mixer_name}"
1239+
dlogi "Reset SOF volume to ${level_db} on ${mixer_name}"
12401240
if [[ "$SOF_ALSA_TOOL" = "alsa" ]]; then
12411241
amixer -Dhw:0 -- sset "$mixer_name" "$level_db"
12421242
elif [[ "$SOF_ALSA_TOOL" = "tinyalsa" ]]; then
12431243
tinymix -D0 set "$mixer_name" "$level_db"
12441244
else
1245-
die "Unknown ALSA tool ${SOF_ALSA_TOOL}"
1245+
dloge "Unknown alsa tool $SOF_ALSA_TOOL"
1246+
break
12461247
fi
12471248
done
12481249
}
12491250

12501251
set_alsa()
12511252
{
1253+
local alsa_log="${LOG_ROOT}/alsa_setup.log"
1254+
1255+
dlogi "Try to initialize all devices to their default ALSA state (alsactl init)."
1256+
printf "-vv------- ALSA init -------vv-" > "${alsa_log}"
1257+
alsactl init >> "${alsa_log}" 2>&1 || rc=$?
1258+
[[ "${rc}" -ne 0 ]] && dloge "alsactl init error=${rc}"
1259+
printf "-^^------- ALSA init -------^^-" >> "${alsa_log}"
1260+
1261+
dlogi "Restore ALSA defaults from /var/lib/alsa/asound.state"
1262+
printf "-vv------- Restore ALSA defaults -------vv-" >> "${alsa_log}"
1263+
# We don't need in sudo to write our alsa_log file, but to call `alsactl restore`.
1264+
# shellcheck disable=SC2024
1265+
sudo alsactl restore >> "${alsa_log}" 2>&1 || rc=$?
1266+
[[ "${rc}" -ne 0 ]] && dloge "alsactl restore error=${rc}"
1267+
printf "-^^------- Restore ALSA defaults -------^^-" >> "${alsa_log}"
1268+
12521269
reset_sof_volume
12531270

12541271
# If MODEL is defined, set proper gain for the platform

0 commit comments

Comments
 (0)