fix: harden adaptive audio resume and release

This commit is contained in:
2026-09-04 17:34:58 +03:00
parent 1431e65768
commit 906e9a0617
4 changed files with 43 additions and 2 deletions

View File

@@ -141,12 +141,13 @@ export const createAdaptiveMixer: AdaptiveMixerFactory = (context, destination)
liftPhase === 'off' ||
liftPhase === 'exiting'
) return;
const entryWillComplete = liftPhase === 'entering';
scheduledStart = nextBeatTime(
now + LIFT_EXIT_DWELL_SECONDS,
transportAnchor,
);
scheduledEnd = scheduledStart + MUSIC_BEAT_SECONDS;
holdParameter(driveLiftGate.gain, now);
if (!entryWillComplete) holdParameter(driveLiftGate.gain, now);
driveLiftGate.gain.setValueAtTime(1, scheduledStart);
driveLiftGate.gain.linearRampToValueAtTime(0, scheduledEnd);
liftPhase = 'exiting';

View File

@@ -499,8 +499,8 @@ export function createSoundtrackEngine(
async resume() {
if (closed) throw new DOMException('Audio graph is closed.', 'InvalidStateError');
await context.resume();
ensureDriveLiftLoad();
if (transportStarted) return;
ensureDriveLiftLoad();
loadPromise ??= loadAndStart();
await loadPromise;
},