diff --git a/ui/src/routes/devices.$id.tsx b/ui/src/routes/devices.$id.tsx index 6b188517..01d0af4b 100644 --- a/ui/src/routes/devices.$id.tsx +++ b/ui/src/routes/devices.$id.tsx @@ -620,7 +620,7 @@ export default function KvmIdRoute() { echoCancellation: true, noiseSuppression: true, autoGainControl: true, - channelCount: 2, + channelCount: 1, } }).then((stream) => { microphoneRequestInProgress.current = false; @@ -652,6 +652,13 @@ export default function KvmIdRoute() { audioTransceiver.sender.replaceTrack(null); } } + + // Cleanup on unmount or when dependencies change + return () => { + if (audioTransceiver?.sender.track) { + audioTransceiver.sender.track.stop(); + } + }; }, [microphoneEnabled, audioTransceiver, peerConnection, setMicrophoneEnabled]); // Cleanup effect diff --git a/webrtc.go b/webrtc.go index 6b8eaeef..6ad978df 100644 --- a/webrtc.go +++ b/webrtc.go @@ -332,6 +332,7 @@ func newSession(config SessionConfig) (*Session, error) { ) if err != nil { scopedLogger.Warn().Err(err).Msg("Failed to create AudioTrack (non-fatal)") + session.AudioTrack = nil } else { _, err = peerConnection.AddTransceiverFromTrack(session.AudioTrack, webrtc.RTPTransceiverInit{ Direction: webrtc.RTPTransceiverDirectionSendrecv,