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
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The sound test runs unconditionally for all matrix variants, including when matrix.dependency == 'none' where no sound library is installed. This will likely cause the test to fail. Consider adding a condition similar to the install step.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/main.yml, line 72:

<comment>The sound test runs unconditionally for all matrix variants, including when `matrix.dependency == &#39;none&#39;` where no sound library is installed. This will likely cause the test to fail. Consider adding a condition similar to the install step.</comment>

<file context>
@@ -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
</file context>
Suggested change
- name: sound test
- name: sound test
if: matrix.dependency != 'none'
Fix with Cubic

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.
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Grammar error: "until semu being rebooted" should be "until semu is rebooted".

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README.md, line 17:

<comment>Grammar error: &quot;until `semu` being rebooted&quot; should be &quot;until `semu` is rebooted&quot;.</comment>

<file context>
@@ -12,12 +12,13 @@ A minimalist RISC-V system emulator capable of running Linux the kernel and corr
-          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
</file context>
Suggested change
the ALSA stack stuck in XRUN state until `semu` being rebooted.
the ALSA stack to get stuck in XRUN state until `semu` is rebooted.
Fix with Cubic

Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Grammar issue: 'stuck' should be 'to get stuck' and 'being rebooted' should be 'is rebooted'.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README.md, line 17:

<comment>Grammar issue: &#39;stuck&#39; should be &#39;to get stuck&#39; and &#39;being rebooted&#39; should be &#39;is rebooted&#39;.</comment>

<file context>
@@ -12,12 +12,13 @@ A minimalist RISC-V system emulator capable of running Linux the kernel and corr
-          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
</file context>
Suggested change
the ALSA stack stuck in XRUN state until `semu` being rebooted.
the ALSA stack to get stuck in XRUN state until `semu` is rebooted.
Fix with Cubic

- 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.
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Grammar error: subject-verb agreement. "ALSA usually get stuck" should be "ALSA usually gets stuck".

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README.md, line 21:

<comment>Grammar error: subject-verb agreement. &quot;ALSA usually get stuck&quot; should be &quot;ALSA usually gets stuck&quot;.</comment>

<file context>
@@ -12,12 +12,13 @@ A minimalist RISC-V system emulator capable of running Linux the kernel and corr
+        - 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
</file context>
Suggested change
- For capture, ALSA usually get stuck in XRUN state, so you may need to try multiple times.
- For capture, ALSA usually gets stuck in XRUN state, so you may need to try multiple times.
Fix with Cubic

Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Subject-verb agreement error: "ALSA usually get stuck" should be "ALSA usually gets stuck".

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README.md, line 21:

<comment>Subject-verb agreement error: &quot;ALSA usually get stuck&quot; should be &quot;ALSA usually gets stuck&quot;.</comment>

<file context>
@@ -12,12 +12,13 @@ A minimalist RISC-V system emulator capable of running Linux the kernel and corr
+        - 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
</file context>
Suggested change
- For capture, ALSA usually get stuck in XRUN state, so you may need to try multiple times.
- For capture, ALSA usually gets stuck in XRUN state, so you may need to try multiple times.
Fix with Cubic


## Prerequisites

Expand Down
Loading
Loading