Skip to content

Commit 1f8a70b

Browse files
committed
TinyAlsa: Add support for testing using tinycap and tinyplay.
Added -T parameter to specify whether to use the TinyASLA or ALSA testing tool. For now, it is only for capturing and playback. The default tool is ALSA. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
1 parent e7c456d commit 1f8a70b

File tree

3 files changed

+57
-10
lines changed

3 files changed

+57
-10
lines changed

case-lib/lib.sh

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -754,15 +754,43 @@ func_lib_check_pa()
754754

755755
aplay_opts()
756756
{
757-
dlogc "aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $*"
758-
# shellcheck disable=SC2086
759-
aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS "$@"
757+
local use_tinyalsa=false # Default is to use aplay (ALSA)
758+
759+
# Check if the first argument is 'tinyalsa'
760+
if [[ "$1" == "tinyalsa" ]]; then
761+
use_tinyalsa=true
762+
fi
763+
shift
764+
if $use_tinyalsa; then
765+
card_nr=$(echo "$dev" | cut -d ':' -f2 | cut -d ',' -f1)
766+
dev_nr=$(echo "$dev" | cut -d ',' -f2)
767+
sox -n -r "$rate" -c "$channel" noise.wav synth "$duration" white
768+
tinyplay -D "$card_nr" -d "$dev_nr" -i wav noise.wav
769+
else
770+
dlogc "aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $*"
771+
# shellcheck disable=SC2086
772+
aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS "$@"
773+
fi
760774
}
761775
arecord_opts()
762776
{
763-
dlogc "arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $*"
764-
# shellcheck disable=SC2086
765-
arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS "$@"
777+
local use_tinyalsa=false # Default is to use arecord (ALSA)
778+
779+
# Check if the first argument is 'tinyalsa'
780+
if [[ "$1" == "tinyalsa" ]]; then
781+
use_tinyalsa=true
782+
fi
783+
shift
784+
if $use_tinyalsa; then
785+
card_nr=$(echo "$dev" | cut -d ':' -f2 | cut -d ',' -f1)
786+
dev_nr=$(echo "$dev" | cut -d ',' -f2)
787+
format=$( echo "$fmt_elem" | grep '[0-9]\+' -o)
788+
tinycap "$file" -D "$card_nr" -d "$dev_nr" -c "$channel" -t "$duration" -r "$rate" -b "$format"
789+
else
790+
dlogc "arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $*"
791+
# shellcheck disable=SC2086
792+
arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS "$@"
793+
fi
766794
}
767795

768796
die()

test-case/check-capture.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
4848
OPT_NAME['S']='filter_string' OPT_DESC['S']="run this case on specified pipelines"
4949
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"
5050

51+
OPT_NAME['T']="tool" OPT_DESC['T']="Tool for testing"
52+
OPT_HAS_ARG['T']=1 OPT_VAL['T']="alsa"
53+
5154
func_opt_parse_option "$@"
5255

5356
tplg=${OPT_VAL['t']}
@@ -56,10 +59,16 @@ duration=${OPT_VAL['d']}
5659
loop_cnt=${OPT_VAL['l']}
5760
out_dir=${OPT_VAL['o']}
5861
file_prefix=${OPT_VAL['f']}
62+
tool=${OPT_VAL['T']}
5963

6064
start_test
6165
logger_disabled || func_lib_start_log_collect
6266

67+
if [[ "$tool" != "tinyalsa" ]] && [[ "$tool" != "alsa" ]]; then
68+
echo "Unknown tool"
69+
exit
70+
fi
71+
6372
setup_kernel_check_point
6473
func_lib_check_sudo
6574
func_pipeline_export "$tplg" "type:capture & ${OPT_VAL['S']}"
@@ -84,7 +93,7 @@ do
8493
do
8594
for i in $(seq 1 $loop_cnt)
8695
do
87-
dlogi "===== Testing: (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
96+
dlogi "===== Testing: (Tool: $tool) (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
8897
# get the output file
8998
if [[ -z $file_prefix ]]; then
9099
dlogi "no file prefix, use /dev/null as dummy capture output"
@@ -95,7 +104,7 @@ do
95104
dlogi "using $file as capture output"
96105
fi
97106

98-
if ! arecord_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" -d $duration "$file" -v -q;
107+
if ! arecord_opts "$tool" -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" -d $duration "$file" -v -q;
99108
then
100109
func_lib_lsof_error_dump "$snd"
101110
die "arecord on PCM $dev failed at $i/$loop_cnt."

test-case/check-playback.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
4545
OPT_NAME['S']='filter_string' OPT_DESC['S']="run this case on specified pipelines"
4646
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"
4747

48+
OPT_NAME['T']='tool' OPT_DESC['T']="Tool for testing"
49+
OPT_HAS_ARG['T']=1 OPT_VAL['T']="alsa"
50+
51+
4852
func_opt_parse_option "$@"
4953

5054
tplg=${OPT_VAL['t']}
5155
round_cnt=${OPT_VAL['r']}
5256
duration=${OPT_VAL['d']}
5357
loop_cnt=${OPT_VAL['l']}
5458
file=${OPT_VAL['f']}
59+
tool=${OPT_VAL['T']}
5560

5661
start_test
5762
logger_disabled || func_lib_start_log_collect
@@ -67,6 +72,11 @@ else
6772
dlogi "using $file as playback source"
6873
fi
6974

75+
if [[ "$tool" != "tinyalsa" ]] && [[ "$tool" != "alsa" ]]; then
76+
echo "Unknown tool"
77+
exit
78+
fi
79+
7080
setup_kernel_check_point
7181
func_lib_check_sudo
7282
func_pipeline_export "$tplg" "type:playback & ${OPT_VAL['S']}"
@@ -91,8 +101,8 @@ do
91101
do
92102
for i in $(seq 1 $loop_cnt)
93103
do
94-
dlogi "===== Testing: (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
95-
aplay_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" \
104+
dlogi "===== Testing: (Tool: $tool) (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
105+
aplay_opts "$tool" -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" \
96106
-d "$duration" "$file" -v -q || {
97107
func_lib_lsof_error_dump "$snd"
98108
die "aplay on PCM $dev failed at $i/$loop_cnt."

0 commit comments

Comments
 (0)