Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent double sound detectors set up #1371

Merged
merged 4 commits into from
May 29, 2024
Merged

fix: prevent double sound detectors set up #1371

merged 4 commits into from
May 29, 2024

Conversation

myandrienko
Copy link
Contributor

Calling startSpeakingWhileMutedDetection multiple types without awaiting leads to multiple sound detectors being set up. Calling stopSpeakingWhileMutedDetection afterwords cleans up only one of them.

Since startSpeakingWhileMutedDetection is called in a callback to an Rx observable, it's very possible that multiple sound detectors will be set up when the state updates fire rapidly.

This fix prevents that.

@myandrienko myandrienko merged commit 51c9198 into main May 29, 2024
20 of 21 checks passed
@myandrienko myandrienko deleted the fix/swmn branch May 29, 2024 11:27
myandrienko added a commit that referenced this pull request Jun 12, 2024
Adds three concurrency helpers:
1. `withoutConcurrency` - accepts async functions and makes sure they
run one after another, and never in parallel.
2. `withCancelation` - does the same thing, but also cancels all other
async functions when a new function is scheduled. Useful for actions
that override each other, like enabling and disabling camera.
3. `createSafeAsyncSubscription` adds an async listener to an Rx
observable, and makes sure listeners never run in parallel, even if
updates come in quicker than handlers can run.

As an example, those utilities are adopted in two places, where ad-hoc
solutions were previously added:
#1371
#1342
myandrienko added a commit that referenced this pull request Jun 12, 2024
Adds three concurrency helpers:
1. `withoutConcurrency` - accepts async functions and makes sure they
run one after another, and never in parallel.
2. `withCancelation` - does the same thing, but also cancels all other
async functions when a new function is scheduled. Useful for actions
that override each other, like enabling and disabling camera.
3. `createSafeAsyncSubscription` adds an async listener to an Rx
observable, and makes sure listeners never run in parallel, even if
updates come in quicker than handlers can run.

As an example, those utilities are adopted in two places, where ad-hoc
solutions were previously added:
#1371
#1342
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants