-
Notifications
You must be signed in to change notification settings - Fork 64
Implement VirtIO sound device capture #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
41fe790
8b5d0cb
60ab79a
5bca780
a8c5d37
7d09cf1
46bbb67
fd9ed70
53751e2
de2d7e4
a7b2bb3
812487e
0e3997e
f266edf
3ea730a
f015729
72b6f7b
b4d45f4
8f20384
2ac448d
5f6c82b
a5cbdc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/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" | ||
|
|
||
| # Override timeout for sound tests | ||
| # Sound tests need different timeout: 30s for Linux, 900s for macOS | ||
| case "${OS_TYPE}" in | ||
| Darwin) | ||
| TIMEOUT=900 | ||
| ;; | ||
| Linux) | ||
| TIMEOUT=30 | ||
| ;; | ||
| *) | ||
| TIMEOUT=30 | ||
| ;; | ||
| esac | ||
|
|
||
| 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 "# " { send "aplay -L\\n" } | ||
| expect "# " { } | ||
| DONE | ||
| } | ||
|
|
||
| # Clean up any existing semu processes before starting tests | ||
| cleanup | ||
|
|
||
| # Test sound device | ||
| test_sound | ||
| echo "✓ sound test passed" | ||
|
|
||
| ret="$?" | ||
|
|
||
| MESSAGES=("OK!" \ | ||
| "Fail to boot" \ | ||
| "Fail to login" \ | ||
| "Playback fails" \ | ||
| "Capture fails" \ | ||
| ) | ||
|
|
||
| if [ "$ret" -eq 0 ]; then | ||
| print_success "${MESSAGES["$ret"]}" | ||
| else | ||
| print_error "${MESSAGES["$ret"]}" | ||
| fi | ||
|
|
||
| exit "$ret" | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,6 +69,10 @@ jobs: | |||||||
| run: sudo .ci/test-netdev.sh | ||||||||
| shell: bash | ||||||||
| timeout-minutes: 10 | ||||||||
| - name: sound test | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: The sound test runs unconditionally for all matrix variants, including when Prompt for AI agents
Suggested change
|
||||||||
| run: .ci/test-sound.sh | ||||||||
| shell: bash | ||||||||
| timeout-minutes: 5 | ||||||||
|
|
||||||||
| semu-macOS: | ||||||||
| runs-on: macos-latest | ||||||||
|
|
@@ -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 | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This sentence has grammatical issues that make it hard to parse. Consider restructuring to: "Due to a confirmed issue, Prompt for AI agents
Suggested change
|
||||||||||
| the ALSA stack will get stuck in XRUN state until you reboot `semu`. | ||||||||||
|
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Grammatical issue: The sentence structure is broken. "As a confirmed issue that... causing... will get stuck" doesn't form a proper sentence. Consider rephrasing to: "Due to a confirmed issue where Prompt for AI agents
Suggested change
|
||||||||||
| - 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 gets stuck in XRUN state, so you may need to try multiple times. | ||||||||||
|
|
||||||||||
| ## Prerequisites | ||||||||||
|
|
||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Exit code is captured from
echoinstead oftest_sound. Withset -e, iftest_soundfails the script exits immediately, making the error messages dead code. The exit status should be captured right aftertest_sound.Prompt for AI agents