Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Runner/suites/Multimedia/Audio/AudioPlayback/Read_me.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ Ensure the following components are present in the target Yocto build:
- Common tools: `pgrep`, `timeout`, `grep`, `wget`, `tar`
- Daemon: `pipewire` or `pulseaudio` must be running

## Overlay Build Support

For overlay builds using audioreach kernel modules, the test automatically:
- Detects the overlay build configuration
- Sets required DMA heap permissions
- Restarts PipeWire service
- Waits for the service to be ready

This happens transparently before tests run. No manual configuration needed.

## Directory Structure

```bash
Expand Down
6 changes: 6 additions & 0 deletions Runner/suites/Multimedia/Audio/AudioPlayback/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ fi
# shellcheck disable=SC1091
. "$TOOLS/lib_video.sh"

if ! setup_overlay_audio_environment; then
log_fail "Overlay audio environment setup failed"
echo "$TESTNAME FAIL" > "$RES_FILE"
exit 1
fi

TESTNAME="AudioPlayback"
RES_FILE="./${TESTNAME}.res"
LOGDIR="results/${TESTNAME}"
Expand Down
11 changes: 10 additions & 1 deletion Runner/suites/Multimedia/Audio/AudioRecord/Read_me.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ Ensure the following components are present in the target Yocto build:
- PulseAudio: `parecord`, `pactl`
- Common tools: `pgrep`, `timeout`, `grep`, `sed`
- Daemon: `pipewire` or `pulseaudio` must be running


## Overlay Build Support

For overlay builds using audioreach kernel modules, the test automatically:
- Detects the overlay build configuration
- Sets required DMA heap permissions
- Restarts PipeWire service
- Waits for the service to be ready

This happens transparently before tests run. No manual configuration needed.

## Directory Structure

Expand Down
6 changes: 6 additions & 0 deletions Runner/suites/Multimedia/Audio/AudioRecord/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ fi
# shellcheck disable=SC1091
. "$TOOLS/audio_common.sh"

if ! setup_overlay_audio_environment; then
log_fail "Overlay audio environment setup failed"
echo "$TESTNAME FAIL" > "$RES_FILE"
exit 1
fi

TESTNAME="AudioRecord"
RES_FILE="./${TESTNAME}.res"
LOGDIR="results/${TESTNAME}"
Expand Down
74 changes: 74 additions & 0 deletions Runner/utils/audio_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,80 @@ audio_timeout_run() {
done
wait "$pid"; return $?
}

# Function: setup_overlay_audio_environment
# Purpose: Configure audio environment for overlay builds (audioreach-based)
# Returns: 0 on success, 1 on failure
# Usage: Call early in audio test initialization, before backend detection

setup_overlay_audio_environment() {
# Detect overlay build
if ! lsmod 2>/dev/null | awk '$1 ~ /^audioreach/ { found=1; exit } END { exit !found }'; then
log_info "Base build detected (no audioreach modules), skipping overlay setup"
return 0
fi

log_info "Overlay build detected (audioreach modules present), configuring environment..."

# Check root permissions
if [ "$(id -u)" -ne 0 ]; then
log_fail "Overlay audio setup requires root permissions"
return 1
fi

# Configure DMA heap permissions
if [ -e /dev/dma_heap/system ]; then
log_info "Setting permissions on /dev/dma_heap/system"
chmod 666 /dev/dma_heap/system || {
log_fail "Failed to chmod /dev/dma_heap/system"
return 1
}
else
log_warn "/dev/dma_heap/system not found, skipping chmod"
fi

# Check systemctl availability
if ! command -v systemctl >/dev/null 2>&1; then
log_fail "systemctl not available, cannot restart pipewire"
return 1
fi

# Restart PipeWire
log_info "Restarting pipewire service..."
if ! systemctl restart pipewire 2>/dev/null; then
log_fail "Failed to restart pipewire service"
return 1
fi

# Wait for PipeWire with polling (max 60s, check every 2s)
log_info "Waiting for pipewire to be ready..."
max_wait=60
elapsed=0
poll_interval=2

while [ $elapsed -lt $max_wait ]; do
# Check if pipewire process is running
if pgrep -x pipewire >/dev/null 2>&1; then
# Verify wpctl can communicate
if command -v wpctl >/dev/null 2>&1 && wpctl status >/dev/null 2>&1; then
log_pass "PipeWire is ready (took ${elapsed}s)"
return 0
fi
fi

sleep $poll_interval
elapsed=$((elapsed + poll_interval))

if [ $((elapsed % 10)) -eq 0 ]; then
log_info "Still waiting for pipewire... (${elapsed}s/${max_wait}s)"
fi
done

# Timeout reached
log_fail "PipeWire failed to become ready within ${max_wait}s"
log_fail "Check 'systemctl status pipewire' and 'journalctl -u pipewire' for details"
return 1
}

# ---------- PipeWire: sinks (playback) ----------
pw_default_speakers() {
Expand Down
Loading