feat: re-acquire mic track when effects require specific audio constraints - #99
Open
antsukanova wants to merge 30 commits into
Open
feat: re-acquire mic track when effects require specific audio constraints#99antsukanova wants to merge 30 commits into
antsukanova wants to merge 30 commits into
Conversation
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
Adds constraint handling to
LocalAudioStreamso audio effects can request specificMediaTrackConstraintson the microphone track. Since Chrome silently ignoresapplyConstraints()for audio processing properties (chromium#40555809), the handler re-acquires the track viagetUserMedia(). Original track settings are saved and restored when the effect releases its constraints on disable/dispose.Keeping the old track alive while calling
getUserMedia()causes Chrome to reuse the existing hardware capture session and silently ignore hardware-level constraints such asechoCancellation. The old track is stopped beforegetUserMedia()to force a fresh session and ensure all constraints are honored.What's changed
addConstraintHandlers— new private method onLocalAudioStreamwired up fromaddEffect(); listens forConstraintsRequired/ConstraintsReleasedevents from the effect and callsreacquireInputTrackreacquireInputTrack— stops the current track before callinggetUserMedia()with the merged baseline + effect constraints; restores mute state and wires the new track into the effect chainAppliableAudioConstraints— extended withsampleRate,sampleSize, andchannelCountfilterToSupportedConstraints— new helper that strips keys not recognized by the browser viagetSupportedConstraints()before passing baseline settings togetUserMedia()effects/loadingEffects/changeOutputTrack— visibility changed fromprivatetoprotectedinLocalStreamto allow access fromLocalAudioStreamgetUserMedia()or effect wiring fails, all effects are disposed andEndedis emitted; if the effect is disposed whilegetUserMedia()is in-flight, the new track is discarded andEndedis emitted to prevent a silent dead streamTesting
autoGainControl: false,noiseSuppression: false,echoCancellation: truegetUserMedia()→ new track discarded,EndedemittedSee code change in web-media-effects
You can use the sdk linked branch with these changes to test: agc-fix-branch-test