Skip to content
Open
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
32 changes: 32 additions & 0 deletions .ci/test-sound.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -euo pipefail

# Source common functions and settings
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export SCRIPT_DIR
source "${SCRIPT_DIR}/common.sh"

SAMPLE_SOUND="/usr/share/sounds/alsa/Front_Center.wav"

test_sound() {
ASSERT expect <<DONE
set timeout ${TIMEOUT}
spawn make check
expect "buildroot login:" { send "root\\n" } timeout { exit 1 }
expect "# " { send "uname -a\\n" } timeout { exit 2 }

expect "riscv32 GNU/Linux" { send "aplay ${SAMPLE_SOUND} --fatal-errors > /dev/null\\n"} timeout { exit 3 }
expect "# " { send "aplay -C -d 3 --fatal-errors -f S16_LE > /dev/null\\n"} timeout { exit 4 }
expect "# " { } timeout { exit 5 }
DONE
}

# Clean up any existing semu processes before starting tests
cleanup

# Test sound device
test_sound
echo "✓ sound test passed"

exit 0
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ jobs:
run: sudo .ci/test-netdev.sh
shell: bash
timeout-minutes: 10
- name: sound test
run: .ci/test-sound.sh
shell: bash
timeout-minutes: 5

semu-macOS:
runs-on: macos-latest
Expand Down Expand Up @@ -118,6 +122,10 @@ jobs:
shell: bash
timeout-minutes: 20
if: ${{ success() }}
- name: sound test
run: .ci/test-sound.sh
shell: bash
timeout-minutes: 20

coding_style:
runs-on: ubuntu-24.04
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ A minimalist RISC-V system emulator capable of running Linux the kernel and corr
- Three types of I/O support using VirtIO standard:
- virtio-blk acquires disk image from the host.
- virtio-net is mapped as TAP interface.
- virtio-snd uses [PortAudio](https://github.com/PortAudio/portaudio) for sound playback on the host with one limitations:
- As some unknown issues in guest Linux OS (confirmed in v6.7 and v6.12), you need
to adjust the buffer size to more than four times of period size, or
the program cannot write the PCM frames into guest OS ALSA stack.
- virtio-snd uses [PortAudio](https://github.com/PortAudio/portaudio) for sound playback and capture on the host with one limitation:
- As a confirmed issue that `semu` cannot send/receive PCM frames in time, causing
the ALSA stack stuck in XRUN state until `semu` being rebooted.
- For playback, you can try to adjust the buffer size to more than four times of period size.
- For instance, the following buffer/period size settings on `aplay` has been tested
with broken and stutter effects yet complete with no any errors: `aplay --buffer-size=32768 --period-size=4096 /usr/share/sounds/alsa/Front_Center.wav`.
- For capture, ALSA usually get stuck in XRUN state, so you may need to try multiple times.

## Prerequisites

Expand Down
Loading
Loading