fix: Broken voice states and connectivity drops

This commit is contained in:
2026-04-11 12:32:22 +02:00
parent 0865c2fe33
commit ef1182d46f
28 changed files with 1244 additions and 162 deletions

View File

@@ -75,6 +75,12 @@ export class VoiceActivityService implements OnDestroy {
this.untrackStream(peerId);
})
);
this.subs.push(
this.voiceConnection.onVoiceConnected.subscribe(() => {
this.ensureAllRemoteStreamsTracked();
})
);
}
trackLocalMic(userId: string, stream: MediaStream): void {
@@ -124,6 +130,10 @@ export class VoiceActivityService implements OnDestroy {
}
const ctx = new AudioContext();
if (ctx.state === 'suspended')
void ctx.resume();
const analyser = ctx.createAnalyser();
const sources = audioTracks.map((track) => ctx.createMediaStreamSource(new MediaStream([track])));
@@ -166,6 +176,18 @@ export class VoiceActivityService implements OnDestroy {
this.stopPolling();
}
private ensureAllRemoteStreamsTracked(): void {
const peers = this.voiceConnection.getConnectedPeers();
for (const peerId of peers) {
const stream = this.voiceConnection.getRemoteVoiceStream(peerId);
if (stream) {
this.trackStream(peerId, stream);
}
}
}
private ensurePolling(): void {
if (this.animFrameId !== null)
return;