Commit 5c72a06
Jeff Boles
fix(audio): prevent device switching loop during initialization on macOS
Fixes #1371
On macOS 15.x, creating a private aggregate device for speaker audio
capture triggers system-wide device change notifications. The DeviceMonitor
was reacting to these events during initialization, causing the audio
pipeline to restart in a loop and never stabilize.
This change adds an initialization_complete flag that prevents device
change events from being processed until both mic and speaker streams
have successfully initialized. The flag is reset when the user explicitly
changes devices to allow proper reinitialization.
Root Cause:
- PR #1471 introduced aggregate device for speaker capture
- Creating "private" aggregate device unexpectedly triggers device change events
- DeviceMonitor caught in reinitialization loop during startup
- Audio pipeline never stabilized, no audio captured
Solution:
- Added Arc<AtomicBool> to track initialization completion
- Device events ignored during initialization phase
- Flag set to true after both mic+speaker streams start
- Flag reset on explicit device changes for proper reinitialization
Testing:
- Verified on macOS 15.7.2 (M4 MacBook Pro)
- Audio capture now works correctly
- No device switching loop observed
- Device changes handled gracefully during recording
- Success message "audio_streams_initialized" confirms stable pipeline
Changes:
- Modified: plugins/listener/src/actors/source.rs (+17 lines)
- No breaking changes
- Backward compatible1 parent 0df8e3d commit 5c72a06
1 file changed
+17
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
| 70 | + | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| |||
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
| |||
121 | 129 | | |
122 | 130 | | |
123 | 131 | | |
| 132 | + | |
124 | 133 | | |
125 | 134 | | |
126 | 135 | | |
| |||
149 | 158 | | |
150 | 159 | | |
151 | 160 | | |
| 161 | + | |
152 | 162 | | |
153 | 163 | | |
154 | 164 | | |
| |||
193 | 203 | | |
194 | 204 | | |
195 | 205 | | |
| 206 | + | |
196 | 207 | | |
197 | 208 | | |
198 | 209 | | |
| |||
250 | 261 | | |
251 | 262 | | |
252 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
253 | 267 | | |
254 | 268 | | |
255 | 269 | | |
| |||
312 | 326 | | |
313 | 327 | | |
314 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
315 | 332 | | |
316 | 333 | | |
317 | 334 | | |
| |||
0 commit comments