fix: bounce silent — AudioRoutingEngine no longer full-tears-down sink on dest change

stopAllPlayback->updateSfRouting->startTrackPlayback reroutes bridge sink
twice during bounce; each dest change previously called this.disconnect()
= BridgeAudioNode teardown + async worklet reload, audio swallowed into
_preBuffer (bounded 64 blocks) forever if worklet never reactivates ->
silent WAV (only old reverb tail). Fix: rely on BridgeAudioNode.connect()
re-pointing _gainNode (already handles dest switch without teardown);
init() only when not ready. Add __sfDiag ROUTE + BRIDGE_AUDIO (frames/
peak/path per sec) to verify at bounce end.
This commit is contained in:
2026-08-24 22:02:31 +07:00
parent 9cd6113086
commit ba7c03ca5e
3 changed files with 13 additions and 3 deletions
+10
View File
@@ -101,6 +101,16 @@
function onAudio(l, r) {
if (!_initialized) init();
var blk = { l: new Float32Array(l), r: new Float32Array(r) };
_frames = (_frames || 0) + blk.l.length;
for (var _i = 0; _i < blk.l.length; _i++) {
var _a = Math.abs(blk.l[_i]); if (_a > (_peak || 0)) _peak = _a;
var _b = Math.abs(blk.r[_i]); if (_b > (_peak || 0)) _peak = _b;
}
if (!_lastDiag || Date.now() - _lastDiag >= 1000) {
_lastDiag = Date.now();
if (window.__sfDiag) window.__sfDiag("BRIDGE_AUDIO frames=" + _frames + " peak=" + (_peak ? (20 * Math.log10(_peak)).toFixed(1) : "-inf") + "dB path=" + (_useWorklet ? "worklet" : (_preBuffer.length ? "preBuffer" : "chunks")));
_peak = 0;
}
if (_useWorklet && _workletNode) {
_workletNode.port.postMessage({ type: 'audio', l: blk.l, r: blk.r });
return;