fix: clamp audio input channels to stereo to prevent WebRTC crash - #67
Open
stevenwritescode wants to merge 1 commit into
Open
Conversation
Multi-channel audio interfaces (e.g. Focusrite Scarlett 18i20 with 20 channels) cause a fatal WebRTC assertion failure because the channel count exceeds kMaxConcurrentChannels (8). Voice chat only needs mono/stereo, so clamp at both the Rust capture layer (cpal config) and the C# audio source creation as a safety net. Fixes decentraland/unity-explorer#8766
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
Multi-channel audio interfaces (e.g. Focusrite Scarlett 18i20 with 20 output channels) cause a fatal process crash when used as the system audio device. The Rust audio capture code takes whatever channel count cpal reports from the device without any limit. This channel count flows through to WebRTC AudioFrame, which has a hard assertion that num_channels <= 8 (kMaxConcurrentChannels). The process aborts immediately:
Fix
Voice chat only needs mono or stereo audio. The fix clamps the channel count at two levels:
This avoids needing to update the bundled WebRTC fork.
Affected devices
Any audio interface reporting >8 channels: Focusrite Scarlett 18i20, Universal Audio Apollo, MOTU 828/1248, RME Fireface, or aggregate audio devices.
Fixes decentraland/unity-explorer#8766
Test plan