Skip to content

Commit fa4a6ef

Browse files
committed
docs: enhance troubleshooting section for ALSA, PipeWire, and PulseAudio
1 parent 5460314 commit fa4a6ef

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,35 @@ export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/opt/homebrew/Cellar/mingw-w64/11
135135

136136
If you receive errors about no default input or output device:
137137

138-
- **Linux/ALSA:** Ensure your user is in the `audio` group and that ALSA is properly configured
139138
- **Linux/PipeWire:** Check that PipeWire is running: `pw-cli info`
140139
- **Linux/PulseAudio:** Check that PulseAudio is running: `pulseaudio --check`
141140
- **macOS:** Check System Preferences > Sound for available devices
142141
- **Mobile (iOS/Android):** Ensure your app has microphone/audio permissions
143142
- **Windows:** Verify your audio device is enabled in Sound Settings
144143

144+
## ALSA, PipeWire, and PulseAudio
145+
146+
When PipeWire or PulseAudio is running, it holds the ALSA `default` device exclusively. A second stream attempting to open it via the ALSA backend will fail with a `DeviceBusy` error. To route audio through the sound server via ALSA, use the bridge devices `pipewire` or `pulse` instead of `default`. Better yet, use the `pipewire` or `pulseaudio` cpal features for native integration.
147+
148+
Reserve `hw:` and `plughw:` device names for targets that have no sound server. On those targets, ensure the user is a member of the `audio` group if the system does not grant audio device access automatically via `logind`.
149+
145150
### Buffer Size Issues
146151

147-
If you experience audio glitches or dropouts:
152+
`BufferSize::Default` uses the system-configured device default, which on **ALSA** can range from a PipeWire quantum (typically 1024 frames) to `u32::MAX` on misconfigured or exotic hardware. A very deep buffer causes samples to be consumed far faster than audible playback, making audio appear to fast-forward ahead of actual output.
153+
154+
Configure the system and/or request a fixed size in your application:
155+
156+
| System | File | Setting |
157+
|--------|------|---------|
158+
| ALSA | `~/.asoundrc` or `/etc/asound.conf` | `buffer_size`, `periods` * `period_size` |
159+
| PipeWire | `~/.config/pipewire/pipewire.conf.d/` | `default.clock.quantum` |
160+
| PulseAudio | `~/.config/pulse/daemon.conf` | `default-fragments` * `default-fragment-size-msec` |
161+
162+
```rust
163+
config.buffer_size = cpal::BufferSize::Fixed(1024);
164+
```
148165

149-
- Try `BufferSize::Default` first before requesting specific sizes
150-
- When using `BufferSize::Fixed`, query `SupportedBufferSize` to find valid ranges
151-
- Smaller buffers reduce latency but increase CPU load and risk dropouts
152-
- Ensure your audio callback completes quickly and avoids blocking operations
166+
Query `device.default_output_config()?.buffer_size()` for valid ranges. Smaller buffers reduce latency but increase CPU load and the risk of glitches.
153167

154168
### Build Errors
155169

0 commit comments

Comments
 (0)