You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-01 04:43:29 +03:00
Properly dispose of CallFeeds
This commit is contained in:
@@ -558,6 +558,10 @@ export class MatrixCall extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private deleteAllFeeds(): void {
|
private deleteAllFeeds(): void {
|
||||||
|
for (const feed of this.feeds) {
|
||||||
|
feed.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
this.feeds = [];
|
this.feeds = [];
|
||||||
this.emit(CallEvent.FeedsChanged, this.feeds);
|
this.emit(CallEvent.FeedsChanged, this.feeds);
|
||||||
}
|
}
|
||||||
@@ -571,6 +575,7 @@ export class MatrixCall extends EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
feed.dispose();
|
||||||
this.feeds.splice(this.feeds.indexOf(feed), 1);
|
this.feeds.splice(this.feeds.indexOf(feed), 1);
|
||||||
this.emit(CallEvent.FeedsChanged, this.feeds);
|
this.emit(CallEvent.FeedsChanged, this.feeds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export class CallFeed extends EventEmitter {
|
|||||||
private frequencyBinCount: Float32Array;
|
private frequencyBinCount: Float32Array;
|
||||||
private speakingThreshold = SPEAKING_THRESHOLD;
|
private speakingThreshold = SPEAKING_THRESHOLD;
|
||||||
private speaking = false;
|
private speaking = false;
|
||||||
|
private volumeLooperTimeout: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public stream: MediaStream,
|
public stream: MediaStream,
|
||||||
@@ -166,7 +167,7 @@ export class CallFeed extends EventEmitter {
|
|||||||
private volumeLooper(): void {
|
private volumeLooper(): void {
|
||||||
if (!this.analyser) return;
|
if (!this.analyser) return;
|
||||||
|
|
||||||
setTimeout(() => {
|
this.volumeLooperTimeout = setTimeout(() => {
|
||||||
if (!this.measuringVolumeActivity) return;
|
if (!this.measuringVolumeActivity) return;
|
||||||
|
|
||||||
this.analyser.getFloatFrequencyData(this.frequencyBinCount);
|
this.analyser.getFloatFrequencyData(this.frequencyBinCount);
|
||||||
@@ -188,4 +189,8 @@ export class CallFeed extends EventEmitter {
|
|||||||
this.volumeLooper();
|
this.volumeLooper();
|
||||||
}, POLLING_INTERVAL);
|
}, POLLING_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public dispose(): void {
|
||||||
|
clearTimeout(this.volumeLooperTimeout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user