fix: Bug 1 keyboard preview cam lan 2+ — token race: stale check != token -> > token (claim-then-compare) trong _sfWasmFallbackNote + API path (T1)
This commit is contained in:
@@ -218,7 +218,7 @@ const _sfWasmFallbackNote = (track, pitch, velocity, durationMs, startTime, key,
|
||||
const bank = (eng && eng.soundfont_bank) || 0;
|
||||
const program = (eng && eng.soundfont_program) || (track && track.instrumentProgram !== undefined ? track.instrumentProgram : 0);
|
||||
const k = key || (track ? track.id : 'global');
|
||||
if (_nativeSfPreviews[k] && token != null && _nativeSfPreviews[k].token !== token) return; // stale
|
||||
if (_nativeSfPreviews[k] && token != null && _nativeSfPreviews[k].token > token) return; // stale (claim-then-compare: chi bo neu co note MOI HON)
|
||||
const S = window.SonicSF;
|
||||
if (!S) return;
|
||||
const ch = (track && track.midiChannel != null) ? track.midiChannel : 0;
|
||||
@@ -264,7 +264,7 @@ const playNativeSfNote = (track, pitch, velocity, durationMs, startTime, key) =>
|
||||
_sfWasmFallbackNote(track, pitch, velocity, durationMs, startTime, k, token);
|
||||
return;
|
||||
}
|
||||
if (_nativeSfPreviews[k] && _nativeSfPreviews[k].token !== token) return; // stale
|
||||
if (_nativeSfPreviews[k] && _nativeSfPreviews[k].token > token) return; // stale (claim-then-compare: chi bo neu co note MOI HON)
|
||||
window.__nativeSfOk = true;
|
||||
const audio = new Audio(API_BASE_URL + res.url);
|
||||
_nativeSfPreviews[k] = { audio: audio, token: token };
|
||||
|
||||
Reference in New Issue
Block a user