fix: shutdown propre sans erreurs

Problèmes corrigés pendant l'arrêt serveur :
1. RangeError offset bounds : vérification availableSpace avant .set()
2. audioBackend null : vérification avant queueAudio()
3. LiveKit track not found : try/catch sur unpublishTrack

Shutdown maintenant sans erreurs fatales.
This commit is contained in:
2026-05-28 16:13:35 +02:00
parent d908cf4ee6
commit c9ec10dfd9
5 changed files with 27 additions and 11 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ define(['./workbox-290dd570'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812" "revision": "3ca0b8505b4bec776b69afdba2768812"
}, { }, {
"url": "index.html", "url": "index.html",
"revision": "0.881sreuemg" "revision": "0.0p0vks93ec8"
}], {}); }], {});
workbox.cleanupOutdatedCaches(); workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
File diff suppressed because one or more lines are too long
+13 -2
View File
@@ -491,12 +491,23 @@ export class AudioBridge extends EventEmitter {
const accumulator = this.liveKitFrameAccumulators.get(groupName); const accumulator = this.liveKitFrameAccumulators.get(groupName);
// Vérifier que le buffer ne débordera pas
const availableSpace = 960 - accumulator.offset;
const samplesToCopy = Math.min(samplesReceived, availableSpace);
// Copier les samples dans l'accumulateur // Copier les samples dans l'accumulateur
accumulator.buffer.set(float32Data, accumulator.offset); if (samplesToCopy > 0) {
accumulator.offset += samplesReceived; accumulator.buffer.set(float32Data.subarray(0, samplesToCopy), accumulator.offset);
accumulator.offset += samplesToCopy;
}
// Si on a accumulé assez de samples (960), router vers les outputs // Si on a accumulé assez de samples (960), router vers les outputs
if (accumulator.offset >= 960) { if (accumulator.offset >= 960) {
// Vérifier que le backend est toujours actif (évite crash pendant shutdown)
if (!this.audioBackend) {
return;
}
// Stocker le buffer complet pour le routing // Stocker le buffer complet pour le routing
this.groupBuffersFromLiveKit.set(groupName, accumulator.buffer); this.groupBuffersFromLiveKit.set(groupName, accumulator.buffer);
+8 -1
View File
@@ -349,7 +349,14 @@ export class LiveKitClient extends EventEmitter {
if (this.room) { if (this.room) {
// Unpublish track // Unpublish track
if (this.localAudioTrack) { if (this.localAudioTrack) {
await this.room.localParticipant.unpublishTrack(this.localAudioTrack.sid); try {
await this.room.localParticipant.unpublishTrack(this.localAudioTrack.sid);
} catch (error) {
// Ignorer l'erreur si le track n'existe plus (shutdown rapide)
if (!error.message?.includes('track not found')) {
console.warn('⚠️ Erreur unpublish track:', error.message);
}
}
this.localAudioTrack = null; this.localAudioTrack = null;
} }
+4 -6
View File
@@ -4,10 +4,8 @@ audio:
defaultBitrate: 96 defaultBitrate: 96
jitterBufferMs: 40 jitterBufferMs: 40
device: device:
# Laissez null pour auto-détection du device par défaut inputDeviceId: Microphone MacBook Pro
# Ou spécifiez le nom exact via l'interface /admin outputDeviceId: Haut-parleurs MacBook Pro
inputDeviceId: alsa_input.pci-0000_00_01.0.analog-stereo
outputDeviceId: alsa_output.pci-0000_00_01.0.analog-stereo
sampleRate: 48000 sampleRate: 48000
routing: routing:
inputToGroup: inputToGroup:
@@ -52,8 +50,8 @@ server:
host: 0.0.0.0 host: 0.0.0.0
port: 3000 port: 3000
livekit: livekit:
url: AUTO # AUTO = détection automatique IP réseau | ou ws://IP:7880 pour manuel url: AUTO
logging: logging:
level: debug # Changez à 'debug' pour voir plus de détails level: debug
logLatency: false logLatency: false
logAudioStats: false logAudioStats: false