Skip to content

Commit 85d00ca

Browse files
authored
Merge pull request qualcomm-linux#218 from tmoida/main
audio: add overlay build environment setup for audioreach
2 parents 0e43198 + 0e4946a commit 85d00ca

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed

Runner/suites/Multimedia/Audio/AudioPlayback/Read_me.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ Ensure the following components are present in the target Yocto build:
2828
- Common tools: `pgrep`, `timeout`, `grep`, `wget`, `tar`
2929
- Daemon: `pipewire` or `pulseaudio` must be running
3030

31+
## Overlay Build Support
32+
33+
For overlay builds using audioreach kernel modules, the test automatically:
34+
- Detects the overlay build configuration
35+
- Sets required DMA heap permissions
36+
- Restarts PipeWire service
37+
- Waits for the service to be ready
38+
39+
This happens transparently before tests run. No manual configuration needed.
40+
3141
## Directory Structure
3242

3343
```bash

Runner/suites/Multimedia/Audio/AudioPlayback/run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ fi
4141
# shellcheck disable=SC1091
4242
. "$TOOLS/lib_video.sh"
4343

44+
if ! setup_overlay_audio_environment; then
45+
log_fail "Overlay audio environment setup failed"
46+
echo "$TESTNAME FAIL" > "$RES_FILE"
47+
exit 1
48+
fi
49+
4450
TESTNAME="AudioPlayback"
4551
RES_FILE="./${TESTNAME}.res"
4652
LOGDIR="results/${TESTNAME}"

Runner/suites/Multimedia/Audio/AudioRecord/Read_me.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ Ensure the following components are present in the target Yocto build:
2727
- PulseAudio: `parecord`, `pactl`
2828
- Common tools: `pgrep`, `timeout`, `grep`, `sed`
2929
- Daemon: `pipewire` or `pulseaudio` must be running
30-
30+
31+
## Overlay Build Support
32+
33+
For overlay builds using audioreach kernel modules, the test automatically:
34+
- Detects the overlay build configuration
35+
- Sets required DMA heap permissions
36+
- Restarts PipeWire service
37+
- Waits for the service to be ready
38+
39+
This happens transparently before tests run. No manual configuration needed.
3140

3241
## Directory Structure
3342

Runner/suites/Multimedia/Audio/AudioRecord/run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ fi
3030
# shellcheck disable=SC1091
3131
. "$TOOLS/audio_common.sh"
3232

33+
if ! setup_overlay_audio_environment; then
34+
log_fail "Overlay audio environment setup failed"
35+
echo "$TESTNAME FAIL" > "$RES_FILE"
36+
exit 1
37+
fi
38+
3339
TESTNAME="AudioRecord"
3440
RES_FILE="./${TESTNAME}.res"
3541
LOGDIR="results/${TESTNAME}"

Runner/utils/audio_common.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,80 @@ audio_timeout_run() {
155155
done
156156
wait "$pid"; return $?
157157
}
158+
159+
# Function: setup_overlay_audio_environment
160+
# Purpose: Configure audio environment for overlay builds (audioreach-based)
161+
# Returns: 0 on success, 1 on failure
162+
# Usage: Call early in audio test initialization, before backend detection
163+
164+
setup_overlay_audio_environment() {
165+
# Detect overlay build
166+
if ! lsmod 2>/dev/null | awk '$1 ~ /^audioreach/ { found=1; exit } END { exit !found }'; then
167+
log_info "Base build detected (no audioreach modules), skipping overlay setup"
168+
return 0
169+
fi
170+
171+
log_info "Overlay build detected (audioreach modules present), configuring environment..."
172+
173+
# Check root permissions
174+
if [ "$(id -u)" -ne 0 ]; then
175+
log_fail "Overlay audio setup requires root permissions"
176+
return 1
177+
fi
178+
179+
# Configure DMA heap permissions
180+
if [ -e /dev/dma_heap/system ]; then
181+
log_info "Setting permissions on /dev/dma_heap/system"
182+
chmod 666 /dev/dma_heap/system || {
183+
log_fail "Failed to chmod /dev/dma_heap/system"
184+
return 1
185+
}
186+
else
187+
log_warn "/dev/dma_heap/system not found, skipping chmod"
188+
fi
189+
190+
# Check systemctl availability
191+
if ! command -v systemctl >/dev/null 2>&1; then
192+
log_fail "systemctl not available, cannot restart pipewire"
193+
return 1
194+
fi
195+
196+
# Restart PipeWire
197+
log_info "Restarting pipewire service..."
198+
if ! systemctl restart pipewire 2>/dev/null; then
199+
log_fail "Failed to restart pipewire service"
200+
return 1
201+
fi
202+
203+
# Wait for PipeWire with polling (max 60s, check every 2s)
204+
log_info "Waiting for pipewire to be ready..."
205+
max_wait=60
206+
elapsed=0
207+
poll_interval=2
208+
209+
while [ $elapsed -lt $max_wait ]; do
210+
# Check if pipewire process is running
211+
if pgrep -x pipewire >/dev/null 2>&1; then
212+
# Verify wpctl can communicate
213+
if command -v wpctl >/dev/null 2>&1 && wpctl status >/dev/null 2>&1; then
214+
log_pass "PipeWire is ready (took ${elapsed}s)"
215+
return 0
216+
fi
217+
fi
218+
219+
sleep $poll_interval
220+
elapsed=$((elapsed + poll_interval))
221+
222+
if [ $((elapsed % 10)) -eq 0 ]; then
223+
log_info "Still waiting for pipewire... (${elapsed}s/${max_wait}s)"
224+
fi
225+
done
226+
227+
# Timeout reached
228+
log_fail "PipeWire failed to become ready within ${max_wait}s"
229+
log_fail "Check 'systemctl status pipewire' and 'journalctl -u pipewire' for details"
230+
return 1
231+
}
158232

159233
# ---------- PipeWire: sinks (playback) ----------
160234
pw_default_speakers() {

0 commit comments

Comments
 (0)