mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
fix(audio): bound realtime voice buffering
This commit is contained in:
1 parent
afbbd1e2d4
commit
d9904fa154
4 files changed
+166
-16
No files matched your search
@@ -20,6 +20,7 @@ All notable changes to WebSpeak are documented here. Versions follow SemVer.
|
|||||||
|
|
||||||
- Replaced the visually off-center settings glyph and normalized icon alignment for settings-related controls across the client.
|
- Replaced the visually off-center settings glyph and normalized icon alignment for settings-related controls across the client.
|
||||||
- Fixed narrow-screen exit and microphone controls so their text-collapse rules apply correctly.
|
- Fixed narrow-screen exit and microphone controls so their text-collapse rules apply correctly.
|
||||||
|
- Bounded browser and gateway voice buffering, reset stale browser playback queues, and exposed low-overhead in-memory audio counters for diagnosing jitter without per-frame log writes.
|
||||||
|
|
||||||
## [0.1.1] — 2026-09-02
|
## [0.1.1] — 2026-09-02
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ src/
|
|||||||
2. Float32 → Int16 conversion → PTT/VOX gate → WebSocket binary send
|
2. Float32 → Int16 conversion → PTT/VOX gate → WebSocket binary send
|
||||||
3. Server accumulates PCM → every 1920 bytes (960 samples, 20ms) → `OpusEncoder.encode()` → `tsClient.sendVoice(opus, 4)`
|
3. Server accumulates PCM → every 1920 bytes (960 samples, 20ms) → `OpusEncoder.encode()` → `tsClient.sendVoice(opus, 4)`
|
||||||
4. Incoming: TS → `voiceData` event → 3-byte header `[codec][clientId BE]` → WS binary → browser `AudioDecoder` → playback
|
4. Incoming: TS → `voiceData` event → 3-byte header `[codec][clientId BE]` → WS binary → browser `AudioDecoder` → playback
|
||||||
|
5. Browser uplink is capped at 10 PCM frames (about 200ms); gateway egress applies a bounded WebSocket byte guard; browser playback resets stale decoder/source queues above 120ms.
|
||||||
|
|
||||||
|
Audio flow counters are kept in memory and exposed in admin session summaries. Do not add per-frame persistent logging to the voice path.
|
||||||
|
|
||||||
### CJS Interop
|
### CJS Interop
|
||||||
`@discordjs/opus` is CommonJS, loaded via:
|
`@discordjs/opus` is CommonJS, loaded via:
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ const { OpusEncoder } = require("@discordjs/opus") as {
|
|||||||
|
|
||||||
const HEARTBEAT_INTERVAL_MS = 30_000;
|
const HEARTBEAT_INTERVAL_MS = 30_000;
|
||||||
const AUDIO_FRAME_BYTES = 1_920;
|
const AUDIO_FRAME_BYTES = 1_920;
|
||||||
|
// A browser audio frame is 20 ms of mono 48 kHz PCM. Keep the server-side
|
||||||
|
// WebSocket egress queue small enough that a slow browser cannot turn old
|
||||||
|
// voice into seconds of latency. Opus frames are variable-sized, so this is
|
||||||
|
// deliberately a byte backpressure guard; the browser also enforces a
|
||||||
|
// time-based playback limit before scheduling decoded audio.
|
||||||
|
const MAX_SERVER_AUDIO_BUFFERED_BYTES = 16_384;
|
||||||
|
|
||||||
export interface VoiceBridgeOptions {
|
export interface VoiceBridgeOptions {
|
||||||
joinTickets: JoinTicketStore;
|
joinTickets: JoinTicketStore;
|
||||||
@@ -34,6 +40,15 @@ export interface AdminSessionSummary {
|
|||||||
tsClientId: number | null;
|
tsClientId: number | null;
|
||||||
channelId: string | null;
|
channelId: string | null;
|
||||||
memberCount: number;
|
memberCount: number;
|
||||||
|
audio: AudioFlowStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AudioFlowStats {
|
||||||
|
ingressFrames: number;
|
||||||
|
ingressDroppedFrames: number;
|
||||||
|
egressFrames: number;
|
||||||
|
egressDroppedFrames: number;
|
||||||
|
egressPeakBufferedBytes: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChannelMember {
|
interface ChannelMember {
|
||||||
@@ -70,6 +85,7 @@ interface WebClientEntry {
|
|||||||
whisperActive: boolean;
|
whisperActive: boolean;
|
||||||
isAlive: boolean;
|
isAlive: boolean;
|
||||||
reconnectTimer: ReturnType<typeof setTimeout> | null;
|
reconnectTimer: ReturnType<typeof setTimeout> | null;
|
||||||
|
audio: AudioFlowStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class VoiceBridge {
|
export class VoiceBridge {
|
||||||
@@ -144,6 +160,7 @@ export class VoiceBridge {
|
|||||||
whisperActive: false,
|
whisperActive: false,
|
||||||
isAlive: true,
|
isAlive: true,
|
||||||
reconnectTimer: null,
|
reconnectTimer: null,
|
||||||
|
audio: createAudioFlowStats(),
|
||||||
};
|
};
|
||||||
this.entries.set(entryId, entry!);
|
this.entries.set(entryId, entry!);
|
||||||
try {
|
try {
|
||||||
@@ -397,7 +414,18 @@ export class VoiceBridge {
|
|||||||
packet[0] = data.codec;
|
packet[0] = data.codec;
|
||||||
packet.writeUInt16BE(data.clientId, 1);
|
packet.writeUInt16BE(data.clientId, 1);
|
||||||
data.data.copy(packet, 3);
|
data.data.copy(packet, 3);
|
||||||
ws.send(packet);
|
const bufferedBytes = ws.bufferedAmount;
|
||||||
|
entry!.audio.egressPeakBufferedBytes = Math.max(entry!.audio.egressPeakBufferedBytes, bufferedBytes);
|
||||||
|
if (bufferedBytes > MAX_SERVER_AUDIO_BUFFERED_BYTES) {
|
||||||
|
entry!.audio.egressDroppedFrames++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ws.send(packet);
|
||||||
|
entry!.audio.egressFrames++;
|
||||||
|
} catch {
|
||||||
|
entry!.audio.egressDroppedFrames++;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tsClient.on("textMessage", (message) => {
|
tsClient.on("textMessage", (message) => {
|
||||||
@@ -434,9 +462,11 @@ export class VoiceBridge {
|
|||||||
if (isBinary) {
|
if (isBinary) {
|
||||||
const frame = typeof data === "string" ? Buffer.from(data) : data;
|
const frame = typeof data === "string" ? Buffer.from(data) : data;
|
||||||
if (!tsReady || frame.length !== AUDIO_FRAME_BYTES) {
|
if (!tsReady || frame.length !== AUDIO_FRAME_BYTES) {
|
||||||
|
entry!.audio.ingressDroppedFrames++;
|
||||||
sendProtocolError(sendJson, "INVALID_AUDIO_FRAME", "音频帧格式无效");
|
sendProtocolError(sendJson, "INVALID_AUDIO_FRAME", "音频帧格式无效");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
entry!.audio.ingressFrames++;
|
||||||
try {
|
try {
|
||||||
if (entry!.opusEncoder) {
|
if (entry!.opusEncoder) {
|
||||||
const encoded = entry!.opusEncoder.encode(frame);
|
const encoded = entry!.opusEncoder.encode(frame);
|
||||||
@@ -537,6 +567,7 @@ export class VoiceBridge {
|
|||||||
tsClientId,
|
tsClientId,
|
||||||
channelId,
|
channelId,
|
||||||
memberCount: entry.members.size,
|
memberCount: entry.members.size,
|
||||||
|
audio: { ...entry.audio },
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -689,6 +720,16 @@ function isChannelRecord(value: unknown): value is { id: string; name: string }
|
|||||||
return Boolean(value) && typeof value === "object" && typeof (value as { id?: unknown }).id === "string" && typeof (value as { name?: unknown }).name === "string";
|
return Boolean(value) && typeof value === "object" && typeof (value as { id?: unknown }).id === "string" && typeof (value as { name?: unknown }).name === "string";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createAudioFlowStats(): AudioFlowStats {
|
||||||
|
return {
|
||||||
|
ingressFrames: 0,
|
||||||
|
ingressDroppedFrames: 0,
|
||||||
|
egressFrames: 0,
|
||||||
|
egressDroppedFrames: 0,
|
||||||
|
egressPeakBufferedBytes: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function mapChannelTree(snapshot: TSDirectorySnapshot): unknown[] {
|
function mapChannelTree(snapshot: TSDirectorySnapshot): unknown[] {
|
||||||
return snapshot.channels.map((channel) => ({
|
return snapshot.channels.map((channel) => ({
|
||||||
id: String(channel.id),
|
id: String(channel.id),
|
||||||
|
|||||||
@@ -121,7 +121,10 @@ export function useVoiceWebSocket() {
|
|||||||
// Playback is kept per client so frames from multiple speakers cannot
|
// Playback is kept per client so frames from multiple speakers cannot
|
||||||
// interleave into one decoder or one scheduling queue.
|
// interleave into one decoder or one scheduling queue.
|
||||||
const remoteDecoders = new Map<number, AudioDecoder>();
|
const remoteDecoders = new Map<number, AudioDecoder>();
|
||||||
|
const remoteDecoderGenerations = new Map<number, number>();
|
||||||
|
let nextRemoteDecoderGeneration = 0;
|
||||||
const remotePlayTimes = new Map<number, number>();
|
const remotePlayTimes = new Map<number, number>();
|
||||||
|
const remotePlaybackSources = new Map<number, Set<AudioBufferSourceNode>>();
|
||||||
const remoteGains = new Map<number, GainNode>();
|
const remoteGains = new Map<number, GainNode>();
|
||||||
const remoteDecodeTimestamps = new Map<number, number>();
|
const remoteDecodeTimestamps = new Map<number, number>();
|
||||||
const volumes = reactive<Record<number, number>>({});
|
const volumes = reactive<Record<number, number>>({});
|
||||||
@@ -130,8 +133,30 @@ export function useVoiceWebSocket() {
|
|||||||
const whisperActive = ref(false);
|
const whisperActive = ref(false);
|
||||||
const speakingTimers = new Map<number, ReturnType<typeof setTimeout>>();
|
const speakingTimers = new Map<number, ReturnType<typeof setTimeout>>();
|
||||||
const SPEAKING_HOLD_MS = 360;
|
const SPEAKING_HOLD_MS = 360;
|
||||||
const MAX_AUDIO_BUFFERED_BYTES = 192_000;
|
const AUDIO_FRAME_SAMPLES = 960;
|
||||||
let droppedAudioFrames = 0;
|
const AUDIO_FRAME_BYTES = AUDIO_FRAME_SAMPLES * 2;
|
||||||
|
const MAX_AUDIO_BUFFERED_FRAMES = 10;
|
||||||
|
const MAX_AUDIO_BUFFERED_BYTES = AUDIO_FRAME_BYTES * MAX_AUDIO_BUFFERED_FRAMES;
|
||||||
|
const MAX_REMOTE_PLAY_AHEAD_SECONDS = 0.12;
|
||||||
|
const MAX_REMOTE_DECODE_QUEUE_FRAMES = 6;
|
||||||
|
const audioDiagnostics = reactive({
|
||||||
|
uplinkFrames: 0,
|
||||||
|
uplinkDroppedFrames: 0,
|
||||||
|
downlinkFrames: 0,
|
||||||
|
playbackResets: 0,
|
||||||
|
peakBufferedBytes: 0,
|
||||||
|
peakPlayAheadMs: 0,
|
||||||
|
peakDecodeQueueFrames: 0,
|
||||||
|
});
|
||||||
|
const audioCounters = { ...audioDiagnostics };
|
||||||
|
let nextAudioDiagnosticsPublishAt = 0;
|
||||||
|
|
||||||
|
function publishAudioDiagnostics(force = false): void {
|
||||||
|
const now = Date.now();
|
||||||
|
if (!force && now < nextAudioDiagnosticsPublishAt) return;
|
||||||
|
nextAudioDiagnosticsPublishAt = now + 1_000;
|
||||||
|
Object.assign(audioDiagnostics, audioCounters);
|
||||||
|
}
|
||||||
|
|
||||||
async function saveAudioPreferences(): Promise<void> {
|
async function saveAudioPreferences(): Promise<void> {
|
||||||
await saveLocalPreferences({
|
await saveLocalPreferences({
|
||||||
@@ -321,9 +346,12 @@ export function useVoiceWebSocket() {
|
|||||||
accumLen = 0;
|
accumLen = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (socket.bufferedAmount > MAX_AUDIO_BUFFERED_BYTES) {
|
const bufferedBytes = socket.bufferedAmount;
|
||||||
|
audioCounters.peakBufferedBytes = Math.max(audioCounters.peakBufferedBytes, bufferedBytes);
|
||||||
|
if (bufferedBytes > MAX_AUDIO_BUFFERED_BYTES) {
|
||||||
accumLen = 0;
|
accumLen = 0;
|
||||||
droppedAudioFrames++;
|
audioCounters.uplinkDroppedFrames++;
|
||||||
|
publishAudioDiagnostics();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
markSpeaking(state.tsClientId);
|
markSpeaking(state.tsClientId);
|
||||||
@@ -340,9 +368,11 @@ export function useVoiceWebSocket() {
|
|||||||
accumLen = need;
|
accumLen = need;
|
||||||
|
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
while (offset + 960 <= accumLen && socket.readyState === WebSocket.OPEN && socket.bufferedAmount <= MAX_AUDIO_BUFFERED_BYTES) {
|
while (offset + AUDIO_FRAME_SAMPLES <= accumLen && socket.readyState === WebSocket.OPEN && socket.bufferedAmount <= MAX_AUDIO_BUFFERED_BYTES) {
|
||||||
socket.send(accumBuf.slice(offset, offset + 960).buffer);
|
socket.send(accumBuf.slice(offset, offset + AUDIO_FRAME_SAMPLES).buffer);
|
||||||
offset += 960;
|
offset += AUDIO_FRAME_SAMPLES;
|
||||||
|
audioCounters.uplinkFrames++;
|
||||||
|
publishAudioDiagnostics();
|
||||||
}
|
}
|
||||||
accumLen -= offset;
|
accumLen -= offset;
|
||||||
if (offset > 0) accumBuf.set(accumBuf.subarray(offset, offset + accumLen), 0);
|
if (offset > 0) accumBuf.set(accumBuf.subarray(offset, offset + accumLen), 0);
|
||||||
@@ -511,14 +541,31 @@ export function useVoiceWebSocket() {
|
|||||||
function playAudioFrame(clientId: number, opusData: Uint8Array): void {
|
function playAudioFrame(clientId: number, opusData: Uint8Array): void {
|
||||||
if (opusData.length < 3) return;
|
if (opusData.length < 3) return;
|
||||||
let decoder = remoteDecoders.get(clientId);
|
let decoder = remoteDecoders.get(clientId);
|
||||||
|
const ctx = getAudioCtx();
|
||||||
|
const now = ctx.currentTime;
|
||||||
|
const scheduledUntil = remotePlayTimes.get(clientId) ?? now;
|
||||||
|
const decodeQueueSize = decoder?.decodeQueueSize ?? 0;
|
||||||
|
audioCounters.peakDecodeQueueFrames = Math.max(audioCounters.peakDecodeQueueFrames, decodeQueueSize);
|
||||||
|
if (
|
||||||
|
decoder &&
|
||||||
|
(scheduledUntil > now + MAX_REMOTE_PLAY_AHEAD_SECONDS || decodeQueueSize >= MAX_REMOTE_DECODE_QUEUE_FRAMES)
|
||||||
|
) {
|
||||||
|
resetRemotePlayback(clientId);
|
||||||
|
decoder = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
if (!decoder) {
|
if (!decoder) {
|
||||||
const ctx = getAudioCtx();
|
|
||||||
const gainNode = ctx.createGain();
|
const gainNode = ctx.createGain();
|
||||||
gainNode.gain.value = (volumes[clientId] ?? 1) * outputVolume.value;
|
gainNode.gain.value = (volumes[clientId] ?? 1) * outputVolume.value;
|
||||||
gainNode.connect(ctx.destination);
|
gainNode.connect(ctx.destination);
|
||||||
remoteGains.set(clientId, gainNode);
|
remoteGains.set(clientId, gainNode);
|
||||||
decoder = new AudioDecoder({
|
const generation = ++nextRemoteDecoderGeneration;
|
||||||
|
const nextDecoder = new AudioDecoder({
|
||||||
output: (chunk: AudioData) => {
|
output: (chunk: AudioData) => {
|
||||||
|
if (remoteDecoderGenerations.get(clientId) !== generation) {
|
||||||
|
chunk.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const { sampleRate, numberOfChannels, numberOfFrames } = chunk;
|
const { sampleRate, numberOfChannels, numberOfFrames } = chunk;
|
||||||
const buffer = ctx.createBuffer(numberOfChannels, numberOfFrames, sampleRate);
|
const buffer = ctx.createBuffer(numberOfChannels, numberOfFrames, sampleRate);
|
||||||
@@ -530,20 +577,48 @@ export function useVoiceWebSocket() {
|
|||||||
const source = ctx.createBufferSource();
|
const source = ctx.createBufferSource();
|
||||||
source.buffer = buffer;
|
source.buffer = buffer;
|
||||||
source.connect(gainNode);
|
source.connect(gainNode);
|
||||||
|
let sources = remotePlaybackSources.get(clientId);
|
||||||
|
if (!sources) {
|
||||||
|
sources = new Set<AudioBufferSourceNode>();
|
||||||
|
remotePlaybackSources.set(clientId, sources);
|
||||||
|
}
|
||||||
|
sources.add(source);
|
||||||
|
source.addEventListener("ended", () => {
|
||||||
|
source.disconnect();
|
||||||
|
sources?.delete(source);
|
||||||
|
if (sources?.size === 0) remotePlaybackSources.delete(clientId);
|
||||||
|
}, { once: true });
|
||||||
let playTime = remotePlayTimes.get(clientId) ?? ctx.currentTime;
|
let playTime = remotePlayTimes.get(clientId) ?? ctx.currentTime;
|
||||||
if (playTime < ctx.currentTime) playTime = ctx.currentTime;
|
if (playTime < ctx.currentTime) playTime = ctx.currentTime;
|
||||||
|
if (playTime + numberOfFrames / sampleRate > ctx.currentTime + MAX_REMOTE_PLAY_AHEAD_SECONDS) {
|
||||||
|
source.disconnect();
|
||||||
|
sources.delete(source);
|
||||||
|
if (sources.size === 0) remotePlaybackSources.delete(clientId);
|
||||||
|
chunk.close();
|
||||||
|
resetRemotePlayback(clientId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
source.start(playTime);
|
source.start(playTime);
|
||||||
remotePlayTimes.set(clientId, playTime + numberOfFrames / sampleRate);
|
remotePlayTimes.set(clientId, playTime + numberOfFrames / sampleRate);
|
||||||
|
audioCounters.peakPlayAheadMs = Math.max(
|
||||||
|
audioCounters.peakPlayAheadMs,
|
||||||
|
Math.round((playTime + numberOfFrames / sampleRate - ctx.currentTime) * 1_000),
|
||||||
|
);
|
||||||
} catch {
|
} catch {
|
||||||
// A decoder can finish while the audio context is being torn down.
|
// A decoder can finish while the audio context is being torn down.
|
||||||
}
|
}
|
||||||
chunk.close();
|
chunk.close();
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
remoteDecoders.delete(clientId);
|
if (remoteDecoderGenerations.get(clientId) === generation) {
|
||||||
|
remoteDecoderGenerations.delete(clientId);
|
||||||
|
remoteDecoders.delete(clientId);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
decoder.configure({ codec: "opus", sampleRate: 48000, numberOfChannels: 1 });
|
nextDecoder.configure({ codec: "opus", sampleRate: 48000, numberOfChannels: 1 });
|
||||||
|
decoder = nextDecoder;
|
||||||
|
remoteDecoderGenerations.set(clientId, generation);
|
||||||
remoteDecoders.set(clientId, decoder);
|
remoteDecoders.set(clientId, decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,11 +626,38 @@ export function useVoiceWebSocket() {
|
|||||||
const timestamp = remoteDecodeTimestamps.get(clientId) ?? 0;
|
const timestamp = remoteDecodeTimestamps.get(clientId) ?? 0;
|
||||||
decoder.decode(new EncodedAudioChunk({ type: "key", timestamp, duration: 20_000, data: opusData }));
|
decoder.decode(new EncodedAudioChunk({ type: "key", timestamp, duration: 20_000, data: opusData }));
|
||||||
remoteDecodeTimestamps.set(clientId, timestamp + 20_000);
|
remoteDecodeTimestamps.set(clientId, timestamp + 20_000);
|
||||||
|
audioCounters.downlinkFrames++;
|
||||||
|
publishAudioDiagnostics();
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore malformed frames; the next valid frame can still be decoded.
|
// Ignore malformed frames; the next valid frame can still be decoded.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearRemotePlayback(clientId: number): void {
|
||||||
|
const decoder = remoteDecoders.get(clientId);
|
||||||
|
if (decoder) {
|
||||||
|
try { decoder.close(); } catch { /* already closed */ }
|
||||||
|
}
|
||||||
|
remoteDecoders.delete(clientId);
|
||||||
|
remoteDecoderGenerations.delete(clientId);
|
||||||
|
remotePlayTimes.delete(clientId);
|
||||||
|
remoteDecodeTimestamps.delete(clientId);
|
||||||
|
const sources = remotePlaybackSources.get(clientId);
|
||||||
|
if (sources) {
|
||||||
|
for (const source of sources) {
|
||||||
|
try { source.stop(); } catch { /* already ended */ }
|
||||||
|
source.disconnect();
|
||||||
|
}
|
||||||
|
remotePlaybackSources.delete(clientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetRemotePlayback(clientId: number): void {
|
||||||
|
clearRemotePlayback(clientId);
|
||||||
|
audioCounters.playbackResets++;
|
||||||
|
publishAudioDiagnostics();
|
||||||
|
}
|
||||||
|
|
||||||
function connect(target: string, channel: string, nickname: string, serverPassword = "", identity = "", rememberIdentity = false, inviteToken = ""): void {
|
function connect(target: string, channel: string, nickname: string, serverPassword = "", identity = "", rememberIdentity = false, inviteToken = ""): void {
|
||||||
disconnect(true);
|
disconnect(true);
|
||||||
lastConnection = { target, channel, nickname, serverPassword, ...(identity ? { identity } : {}), rememberIdentity };
|
lastConnection = { target, channel, nickname, serverPassword, ...(identity ? { identity } : {}), rememberIdentity };
|
||||||
@@ -664,8 +766,8 @@ export function useVoiceWebSocket() {
|
|||||||
members.length = 0;
|
members.length = 0;
|
||||||
channels.length = 0;
|
channels.length = 0;
|
||||||
chatMessages.length = 0;
|
chatMessages.length = 0;
|
||||||
for (const decoder of remoteDecoders.values()) decoder.close();
|
for (const clientId of new Set([...remoteDecoders.keys(), ...remotePlaybackSources.keys()])) clearRemotePlayback(clientId);
|
||||||
remoteDecoders.clear();
|
remoteDecoderGenerations.clear();
|
||||||
remotePlayTimes.clear();
|
remotePlayTimes.clear();
|
||||||
remoteDecodeTimestamps.clear();
|
remoteDecodeTimestamps.clear();
|
||||||
for (const gain of remoteGains.values()) gain.disconnect();
|
for (const gain of remoteGains.values()) gain.disconnect();
|
||||||
@@ -715,8 +817,10 @@ export function useVoiceWebSocket() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "memberLeave": {
|
case "memberLeave": {
|
||||||
clearSpeaking(Number(msg.id));
|
const clientId = Number(msg.id);
|
||||||
const index = members.findIndex((member) => member.id === msg.id);
|
clearSpeaking(clientId);
|
||||||
|
clearRemotePlayback(clientId);
|
||||||
|
const index = members.findIndex((member) => member.id === clientId);
|
||||||
if (index >= 0) members.splice(index, 1);
|
if (index >= 0) members.splice(index, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -980,6 +1084,7 @@ export function useVoiceWebSocket() {
|
|||||||
outputDeviceSupported,
|
outputDeviceSupported,
|
||||||
audioPermission,
|
audioPermission,
|
||||||
audioContextState,
|
audioContextState,
|
||||||
|
audioDiagnostics,
|
||||||
identityMaterial,
|
identityMaterial,
|
||||||
micLevel,
|
micLevel,
|
||||||
microphoneTestActive,
|
microphoneTestActive,
|
||||||
|
|||||||
Reference in new issue
Block a user