fix(livekit): treat a negative ADM device count as zero devices - #1472
Closed
RaphaelFakhri wants to merge 2 commits into
Closed
RaphaelFakhri wants to merge 2 commits into
RaphaelFakhri wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
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
PlatformAudio::recording_devices()andplayout_devices()iterate overusize::MAXindices when the audio device module reports a negative device count.The module returns a negative value (
-1) when it is not initialized or fails to enumerate.recording_device_count()andplayout_device_count()cast thati16tousize, which wraps to18446744073709551615. The iterator then walks every index at 100% CPU. This is the symptom described in #1468, where the platform ADM is left uninitialized after the last peer connection is released.Changes
device_count, which maps a negative count to zero, and use it for both counts.livekitpatch changeset.This does not change the cause of the negative count in #1468. It makes the API return no devices instead of spinning.
Testing
cargo test -p livekit --lib device_countnegative_device_count_is_zerofails (1 passed, 1 failed).cargo fmt -p livekit -- --checkreports no changes.