fix(midi): prefix _pushEnter/_pushSent/_pushOk/_pushFail with this. — ReferenceError blocked dispatchMidiEvent (v=202608250116)

This commit is contained in:
2026-08-25 07:58:14 +07:00
parent 388da8b380
commit 8ef1935068
2 changed files with 7 additions and 7 deletions
@@ -124,8 +124,8 @@
* data2/data3 (A12): CC value / program / PB LSB|MSB.
*/
dispatchMidiEvent: function (cmd, channel, pitch, velocity, sampleOffset, data2, data3, live) {
_pushEnter = (_pushEnter || 0) + 1;
if (_pushEnter % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_ENTER cmd=' + cmd + ' ch=' + channel + ' tauri=' + !!this._tauri());
this._pushEnter = (this._pushEnter || 0) + 1;
if (this._pushEnter % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_ENTER cmd=' + cmd + ' ch=' + channel + ' tauri=' + !!this._tauri());
if (!this._tauri()) return false;
var safeVelocity = Math.floor(Math.min(1.0, Math.max(0.0, velocity)) * 127);
var byteCmd;
@@ -135,8 +135,8 @@
case 'PITCH_BEND': byteCmd = 0xE; break;
default: byteCmd = cmd === 'NOTE_ON' ? 0x9 : 0x8; break;
}
_pushSent = (_pushSent || 0) + 1;
if (_pushSent % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_SENT ' + _pushSent);
this._pushSent = (this._pushSent || 0) + 1;
if (this.pushSent % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_SENT ' + _pushSent);
// DIAG: Promise.race 800ms — invoke gửi đi nhưng không settle -> timeout
// (phan biet main-thread block vs Rust hang).
Promise.race([
@@ -152,10 +152,10 @@
}),
new Promise(function (_, rej) { setTimeout(function () { rej(new Error('timeout-800ms')); }, 800); })
]).then(function () {
_pushOk = (_pushOk || 0) + 1;
this._pushOk = (this._pushOk || 0) + 1;
if ((_pushOk + (_pushFail || 0)) % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_MIDI ok=' + _pushOk + ' fail=' + (_pushFail || 0));
}).catch(function (e) {
_pushFail = (_pushFail || 0) + 1;
this._pushFail = (this._pushFail || 0) + 1;
if (_lastPushFail !== String(e)) { _lastPushFail = String(e); if (window.__sfDiag) window.__sfDiag('PUSH_MIDI_FAIL ' + e); }
console.warn('[BridgeService] push_midi_event:', e);
});