forked from bondagit/aes67-linux-daemon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_demo.sh
executable file
·98 lines (78 loc) · 2.32 KB
/
run_demo.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#
# Tested on Ubuntu 18.04
#
function cleanup {
#kill and wait for previous daemon instances to exit
sudo killall -q ptp4l
killall -q aes67-daemon
while killall -0 aes67-daemon 2>/dev/null ; do
sleep 1
done
}
if ! [ -x "$(command -v ptp4l)" ]; then
echo 'Error: ptp4l is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v arecord)" ]; then
echo 'Error: arecord is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v speaker-test)" ]; then
echo 'Error: speaker-test is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v ./daemon/aes67-daemon)" ]; then
echo 'Error: aes67-daemon is not compiled.' >&2
exit 1
fi
if ! [ -r "3rdparty/ravenna-alsa-lkm/driver/MergingRavennaALSA.ko" ]; then
echo 'Error: MergingRavennaALSA.ko module is not compiled.' >&2
exit 1
fi
trap cleanup EXIT
#configure system parms
sudo sysctl -w net/ipv4/igmp_max_memberships=66
if [ -x /usr/bin/pulseaudio ]; then
#stop pulseaudio, this seems to open/close ALSA continuosly
echo autospawn = no > $HOME/.config/pulse/client.conf
pulseaudio --kill >/dev/null 2>&1
rm $HOME/.config/pulse/client.conf
#disable pulseaudio
systemctl --user stop pulseaudio.socket > /dev/null 2>&1
systemctl --user stop pulseaudio.sservice > /dev/null 2>&1
fi
#install kernel module
sudo insmod 3rdparty/ravenna-alsa-lkm/driver/MergingRavennaALSA.ko
cleanup
if [ -f ./demo/sink_test.wav ] ; then
rm -f sink_test.wav
fi
echo "Starting PTP master ..."
sudo ptp4l -i lo -l7 -E -S &
#echo "Starting AES67 daemon ..."
./daemon/aes67-daemon -c ./demo/daemon.conf &
#open browser on configuration page
if [ -x "$(command -v xdg-open)" ]; then
xdg-open "http://127.0.0.1:8080/PTP"
fi
echo "Waiting for PTP slave to sync ..."
sleep 30
#starting recording on sink
echo "Starting to record 60 secs from sink ..."
arecord -D plughw:RAVENNA -f S32_LE -d 60 -r 48000 -c 8 -t wav /tmp/sink_test.wav > /dev/null 2>&1 &
sleep 10
#starting playback on source
echo "Starting to playback test on source ..."
speaker-test -F S32_LE -D plughw:RAVENNA -r 48000 -c 8 -t sine > /dev/null 2>&1 &
while killall -0 arecord 2>/dev/null ; do
sleep 1
done
killall speaker-test
if [ -f /tmp/sink_test.wav ] ; then
mv /tmp/sink_test.wav demo/
echo "Recording to file \"demo/sink_test.wav\" successfull"
else
echo "Recording failed"
fi
echo "Terminating processes ..."