Skip to content

Commit

Permalink
fix: restore the original stream on disposing effects (#16)
Browse files Browse the repository at this point in the history
* fix: restore the original stream on disposing effects

* fix: add size check and clear afterward

Co-authored-by: Shaofan Qi (shaqi) <[email protected]>
  • Loading branch information
shaofan-qi and Shaofan Qi (shaqi) authored Dec 6, 2022
1 parent b5c6a0e commit 981c1de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/media/local-track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ export abstract class LocalTrack extends EventEmitter<TrackEvents> {
* Cleanup local microphone track.
*/
disposeEffects(): void {
this.effects.forEach((effect: TrackEffect) => effect.dispose());
if (this.effects.size > 0) {
this.effects.forEach((effect: TrackEffect) => effect.dispose());
this.effects.clear();

this.underlyingStream = this.originalStream;
this.emit(LocalTrackEvents.UnderlyingTrackChange);
}
}
}

0 comments on commit 981c1de

Please sign in to comment.