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"
}, {
"url": "index.html",
"revision": "0.881sreuemg"
"revision": "0.0p0vks93ec8"
}], {});
workbox.cleanupOutdatedCaches();
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);
// 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
accumulator.buffer.set(float32Data, accumulator.offset);
accumulator.offset += samplesReceived;
if (samplesToCopy > 0) {
accumulator.buffer.set(float32Data.subarray(0, samplesToCopy), accumulator.offset);
accumulator.offset += samplesToCopy;
}
// Si on a accumulé assez de samples (960), router vers les outputs
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
this.groupBuffersFromLiveKit.set(groupName, accumulator.buffer);
+8 -1
View File
@@ -349,7 +349,14 @@ export class LiveKitClient extends EventEmitter {
if (this.room) {
// Unpublish track
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;
}
+4 -6
View File
@@ -4,10 +4,8 @@ audio:
defaultBitrate: 96
jitterBufferMs: 40
device:
# Laissez null pour auto-détection du device par défaut
# Ou spécifiez le nom exact via l'interface /admin
inputDeviceId: alsa_input.pci-0000_00_01.0.analog-stereo
outputDeviceId: alsa_output.pci-0000_00_01.0.analog-stereo
inputDeviceId: Microphone MacBook Pro
outputDeviceId: Haut-parleurs MacBook Pro
sampleRate: 48000
routing:
inputToGroup:
@@ -52,8 +50,8 @@ server:
host: 0.0.0.0
port: 3000
livekit:
url: AUTO # AUTO = détection automatique IP réseau | ou ws://IP:7880 pour manuel
url: AUTO
logging:
level: debug # Changez à 'debug' pour voir plus de détails
level: debug
logLatency: false
logAudioStats: false