fix: reset hwOverdrive in all voice cleanup paths
Add hwOverdrive: false to resetSession(), leaveVoice(), and handleForceDisconnect() store resets. Add deactivateHwOverdrive() to disconnect callback and cleanup effect in useLiveKit. Ensures "resets when stream ends" contract holds for edge cases like server shutdown, identity collision, and logout.
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
|||||||
resolveNativeOverdrive,
|
resolveNativeOverdrive,
|
||||||
} from '../utils/screenShare';
|
} from '../utils/screenShare';
|
||||||
import { getMediaStreamTrack } from '../utils/livekitInternals';
|
import { getMediaStreamTrack } from '../utils/livekitInternals';
|
||||||
|
import { deactivate as deactivateHwOverdrive } from '../utils/hwOverdrive';
|
||||||
|
|
||||||
let _activeRoom: Room | null = null;
|
let _activeRoom: Room | null = null;
|
||||||
let _publishedScreenShareCodec: 'vp9' | 'h264' | null = null;
|
let _publishedScreenShareCodec: 'vp9' | 'h264' | null = null;
|
||||||
@@ -560,6 +561,7 @@ export function useLiveKit() {
|
|||||||
const disconnect = useCallback(async () => {
|
const disconnect = useCallback(async () => {
|
||||||
_connectGeneration++;
|
_connectGeneration++;
|
||||||
SpeakingDetector.getInstance().clear();
|
SpeakingDetector.getInstance().clear();
|
||||||
|
deactivateHwOverdrive();
|
||||||
connectedChannelRef.current = null;
|
connectedChannelRef.current = null;
|
||||||
setConnectedChannelId(null);
|
setConnectedChannelId(null);
|
||||||
if (roomRef.current) {
|
if (roomRef.current) {
|
||||||
@@ -650,7 +652,7 @@ export function useLiveKit() {
|
|||||||
}, [room, screenShareConfig, isScreenSharing, isCameraOn, hwOverdrive]);
|
}, [room, screenShareConfig, isScreenSharing, isCameraOn, hwOverdrive]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => { _connectGeneration++; SpeakingDetector.getInstance().clear(); if (roomRef.current) { destroyRoom(roomRef.current); roomRef.current = null; _activeRoom = null; } };
|
return () => { _connectGeneration++; SpeakingDetector.getInstance().clear(); deactivateHwOverdrive(); if (roomRef.current) { destroyRoom(roomRef.current); roomRef.current = null; _activeRoom = null; } };
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -401,6 +401,7 @@ export const useVoiceStore = create<VoiceState>()(
|
|||||||
|
|
||||||
resetSession: () => set({
|
resetSession: () => set({
|
||||||
// Connection state
|
// Connection state
|
||||||
|
hwOverdrive: false,
|
||||||
voiceUsers: new Map(),
|
voiceUsers: new Map(),
|
||||||
voiceUserStates: new Map(),
|
voiceUserStates: new Map(),
|
||||||
currentVoiceChannelId: null,
|
currentVoiceChannelId: null,
|
||||||
@@ -459,6 +460,7 @@ export const useVoiceStore = create<VoiceState>()(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
currentVoiceChannelId: null,
|
currentVoiceChannelId: null,
|
||||||
|
hwOverdrive: false,
|
||||||
isCameraOn: false,
|
isCameraOn: false,
|
||||||
isScreenSharing: false,
|
isScreenSharing: false,
|
||||||
participants: [],
|
participants: [],
|
||||||
@@ -493,6 +495,7 @@ export const useVoiceStore = create<VoiceState>()(
|
|||||||
handleForceDisconnect: () => {
|
handleForceDisconnect: () => {
|
||||||
set({
|
set({
|
||||||
currentVoiceChannelId: null,
|
currentVoiceChannelId: null,
|
||||||
|
hwOverdrive: false,
|
||||||
isCameraOn: false,
|
isCameraOn: false,
|
||||||
isScreenSharing: false,
|
isScreenSharing: false,
|
||||||
participants: [],
|
participants: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user