mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 14:55:43 +00:00
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.
This commit is contained in:
@@ -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; });
|
||||
|
||||
Reference in New Issue
Block a user