summaryrefslogtreecommitdiffstats
path: root/test/mxc_amix_test/test-input1.sh
blob: d6fe88b5aec4bd3f66a40c47c72a7283f794cb7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash

dir_name=$(dirname $0)
script_name=$(basename $0)
sample_name=${script_name%.*}

if [ "$#" != "2" ]; then
	echo "Please provide WAV file for playback and recording rate as parameters."
	exit -1
fi

if [ -r $dir_name/amixenv.sh ]
then
	source $dir_name/amixenv.sh
else
	echo "$dir_name/amixenv.sh is missing!"
	exit -1
fi

areccmd="arecord -q -D hw:${devices[0]} -f S32_LE -c 2 -r $2 -t wav $sample_name.wav"
procs=(
	"aplay -q -D hw:${devices[0]} $1"
)
pids=()

# Use TDM1 as mixer clock
prepare_tdm TDM1

echo " =============================="
echo " AMIX Test Play on hw:${devices[0]}"
echo " =============================="
echo "    Play $1 on hw:${devices[0]}"
echo "    Record $sample_name.wav on hw:${devices[0]}"
echo " =============================="

$areccmd &
arecpid=($!)

for i in "${procs[@]}"
do
	cmd="$i"
	$cmd &
	pids+=($!)
done
####################################
# Test starts here
####################################
sleep 0.01
amixer -q -c $card cset name="Output Source" TDM1

####################################
for pid in "${pids[@]}"
do
	wait $pid
done

kill -3 $arecpid

echo " =============================="
echo " AMIX Test finished, please check $sample_name.wav"
exit 0