Skip to content

Commit

Permalink
multiple-pause-resume.sh: Check for aplay/arecord pid when waiting
Browse files Browse the repository at this point in the history
It has been observed that the expect process has been terminated (pidof
returns with no PID) but the child aplay is still running.
This only happens with ChainDMA enabled PCMs where the time to stop
the stream takes more than 100ms (from trigger stop to PCM close).
With the right timing on such PCM the pidof expect will break the wait
loop and we progress to the next iteration which - again with right
timing and setup - might fail if the aplay is still in a process of closing
and the next iteration includes the same PCM.

Add the aplay and arecord commands to the pidof command to make sure that
the iteration has been completed before starting a new one.
We will still catch timeouts and in that case we  should kill the stuck
processes.

Signed-off-by: Peter Ujfalusi <[email protected]>
  • Loading branch information
ujfalusi authored and marc-hb committed Jul 20, 2024
1 parent 4cfdaab commit 6fec8e0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test-case/multiple-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,28 @@ do
# It's very far from perfect but it helps a little bit.
sleep 0.1
done
# wait for expect script finished
dlogi "wait for expect process finished"
# wait for aplay/arecord finished
dlogi "wait for expect/aplay/arecord process finished"
iwait=$max_wait_time
while [ $iwait -gt 0 ]
do
iwait=$((iwait - 1))
sleep 1s
[[ ! "$(pidof expect)" ]] && break
[[ ! "$(pidof expect aplay arecord)" ]] && break
done
# fix aplay/arecord last output
# Catch timout after the wait loop
echo
if [ "$(pidof expect)" ]; then
if [ "$(pidof expect aplay arecord)" ]; then
dloge "Still have expect process not finished after wait for $max_wait_time"
# list aplay/arecord processes
# list expect/aplay/arecord processes
pgrep -a -f expect || true
pgrep -a -f aplay || true
pgrep -a -f arecord || true

# kill aplay/arecord
sof-process-kill.sh ||
dlogw "Kill process catch error"

exit 1
fi
# now check for all expect quit status
Expand Down

0 comments on commit 6fec8e0

Please sign in to comment.