From 71a8ad673d2a02b4e320df3e61a800a1184acf66 Mon Sep 17 00:00:00 2001 From: Psychotoxical <171614930+Psychotoxical@users.noreply.github.com> Date: Mon, 15 Jun 2026 22:59:52 +0200 Subject: [PATCH] diag(#1094): instrument device-reset handler (pause-restart on macOS) Log the device-reset path the same way as device-changed: payload, the currentTrack/isPlaying snapshot, and whether it restarts playback or correctly takes the paused branch. Pinpoints whether the macOS headphone-disconnect restart is a snapshot bug (isPlaying wrongly true) or cpal-internal. TEMPORARY. --- src/hooks/tauriBridge/useAudioDeviceBridge.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hooks/tauriBridge/useAudioDeviceBridge.ts b/src/hooks/tauriBridge/useAudioDeviceBridge.ts index 8133da3d..ea687b32 100644 --- a/src/hooks/tauriBridge/useAudioDeviceBridge.ts +++ b/src/hooks/tauriBridge/useAudioDeviceBridge.ts @@ -57,6 +57,7 @@ export function useAudioDeviceBridge() { useEffect(() => { let unlisten: (() => void) | undefined; listen('audio:device-reset', (event) => { + diag1090(`device-reset received payload=${JSON.stringify(event.payload)}`); useAuthStore.getState().setAudioOutputDevice(null); // null payload = Rust handled internal replay on the new default device. @@ -64,6 +65,7 @@ export function useAudioDeviceBridge() { const resumeAt = typeof event.payload === 'number' ? event.payload : 0; const { currentTrack, isPlaying, playTrack, resetAudioPause } = usePlayerStore.getState(); + diag1090(`device-reset state currentTrack=${!!currentTrack} isPlaying=${isPlaying} resumeAt=${resumeAt}`); if (!currentTrack) return; if (isPlaying) { if (resumeAt > 0.5 && currentTrack.duration > 0) { @@ -73,8 +75,11 @@ export function useAudioDeviceBridge() { setAtMs: Date.now(), }); } + diag1090('device-reset: before playTrack (RESTARTS PLAYBACK)'); playTrack(currentTrack); + diag1090('device-reset: after playTrack (returned)'); } else { + diag1090('device-reset: paused → resetAudioPause (no restart)'); resetAudioPause(); } }).then(u => { unlisten = u; });