Skip to content

Commit 3ec5054

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 4fb2d67 commit 3ec5054

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

case-lib/lib.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,13 +1242,29 @@ reset_sof_volume()
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+
die "Unknown ALSA tool $SOF_ALSA_TOOL"
12461246
fi
12471247
done
12481248
}
12491249

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

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

0 commit comments

Comments
 (0)