1fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burk#!/system/bin/sh
2fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burk# Run a loopback test in the background after a delay.
3a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk# To run the script, enter these commands once:
4a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#    adb disable-verity
5a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#    adb reboot
6a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#    adb remount
7a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#    adb sync
8a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#    adb push loopback.sh /data/
9a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk# For each test run:
10fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burk#    adb shell "nohup sh /data/loopback.sh &"
11a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk# Quickly connect USB audio if needed, either manually or via Tigertail switch.
12a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk# Wait until the test completes, restore USB to host if needed, and then:
13a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#    adb pull /data/loopreport.txt
14a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#    adb pull /data/loopback_all.wav
15a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#    adb pull /data/loopback_echos.wav
16fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burk
17fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil BurkSLEEP_TIME=10
18a2951c5943172b122cfbfd4098b4f6738eab207dPhil BurkTEST_COMMAND="/data/nativetest/aaudio_loopback/aaudio_loopback -pl -Pl -C1 -n2 -m2 -te -d5"
19a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk# Partial list of options:
20a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#   -pl (output) performance mode: low latency
21a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#   -Pl input performance mode: low latency
22a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#   -C1 input channel count: 1
23a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#   -n2 number of bursts: 2
24a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#   -m2 mmap policy: 2
25a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#   -t? test mode: -tm for sine magnitude, -te for echo latency, -tf for file latency
26a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk#   -d5 device ID
27a2951c5943172b122cfbfd4098b4f6738eab207dPhil Burk# For full list of available options, see AAudioArgsParser.h and loopback.cpp
28fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burk
29fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burkecho "Plug in USB Mir and Fun Plug."
30fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burkecho "Test will start in ${SLEEP_TIME} seconds: ${TEST_COMMAND}"
31fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burksleep ${SLEEP_TIME}
32fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burkdate > /data/loopreport.txt
33fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burk${TEST_COMMAND} >> /data/loopreport.txt
34fcf9efd59e36759ee7df66fdfce4f8eedeb376e4Phil Burkdate >> /data/loopreport.txt
35