@@ -1534,47 +1534,86 @@ restore_topology() {
15341534 check_topology
15351535}
15361536
1537+ # Check aplay output for warnings
1538+ # Arguments: 1-aplay output
1539+ check_for_aplay_warnings ()
1540+ {
1541+ dlogi " $1 "
1542+ if echo " $1 " | grep -q " Warning:" ; then
1543+ dlogw " Caught aplay warning!"
1544+ return 1
1545+ fi
1546+ return 0
1547+ }
1548+
15371549# Play sound and record it
15381550# Arguments: 1-arecord options 2-aplay options
15391551play_and_record ()
15401552{
1553+ errors=0
15411554 dlogi " Play [aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2 ] and capture sound [arecord $1 ]"
15421555 # shellcheck disable=SC2086
15431556 arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $1 & PID=$!
1557+ # shellcheck disable=SC2181
1558+ if [ $? -ne 0 ]; then
1559+ errors=$(( errors+ 1 ))
1560+ fi
15441561 # shellcheck disable=SC2086
1545- aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2
1562+ aplay_output=$( aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2 2>&1 )
1563+ # shellcheck disable=SC2181
1564+ if [ $? -ne 0 ]; then
1565+ errors=$(( errors+ 1 ))
1566+ fi
15461567 wait $PID
15471568 sleep 1
1569+ if ! check_for_aplay_warnings " $aplay_output " ; then
1570+ errors=$(( errors+ 1 ))
1571+ fi
1572+
1573+ if [ " $errors " = 0 ]; then
1574+ return 0
1575+ fi
1576+ return 1
15481577}
15491578
1550- # Analyze files to look for glitches.
1579+ # Analyze file to look for glitches.
15511580# Returns exit code 0 if there are no glitches, 1 if there are.
1552- # Arguments: the list of filenames
1581+ # Arguments: filename
15531582check_soundfile_for_glitches ()
15541583{
1555- glitched_files=0
1584+ if [ -f " $result_filename " ]; then
1585+ dlogi " Analyzing $result_filename file..."
1586+ if python3 " $SCRIPT_HOME " /tools/analyze-wav.py " $result_filename " ; then
1587+ dlogi " $result_filename file is correct"
1588+ else
1589+ dlogw " GLITCHED FILE: $result_filename "
1590+ return 1
1591+ fi
1592+ else
1593+ dlogw " MISSING FILE: $result_filename "
1594+ return 1
1595+ fi
1596+ }
1597+
1598+ # Check list of soundfiles for glitches
1599+ # Returns exit code 0 if there are no glitches, 1 if there are.
1600+ # Arguments: list of filenames
1601+ check_soundfiles_for_glitches ()
1602+ {
1603+ failures=0
15561604 # shellcheck disable=SC2154
15571605 for result_filename in " ${all_result_files[@]} "
15581606 do
1559- if [ -f " $result_filename " ]; then
1560- dlogi " Analyzing $result_filename file..."
1561- if python3 " $SCRIPT_HOME " /tools/analyze-wav.py " $result_filename " ; then
1562- dlogi " $result_filename file is correct"
1563- else
1564- dlogw " Found issues in $result_filename file"
1565- glitched_files=$(( glitched_files+ 1 ))
1566- fi
1567- else
1568- dlogw " $result_filename file not found, check for previous errors"
1569- glitched_files=$(( glitched_files+ 1 ))
1607+ if ! check_soundfile_for_glitches " $result_filename " ; then
1608+ failures=$(( failures+ 1 ))
15701609 fi
15711610 done
15721611
1573- if [ $glitched_files -eq 0 ]; then
1574- dlogi " Analysis finished, no issues found "
1612+ if [ " $failures " = 0 ]; then
1613+ dlogi " All files correct "
15751614 return 0
15761615 else
1577- dlogi " $glitched_files files corrupted"
1616+ dlogw " Found $failures corrupted files "
15781617 return 1
15791618 fi
15801619}
0 commit comments