fix(bridge): 3 bug âm thanh Qin/Nexus standalone

1) wavesynth tự phát khi mở app: probe calibrate() render vào live mix
   (renderAll process cùng instance) -> thêm calibratingCh_[16], renderAll
   bỏ qua channel đang calibrate; plugin_host panic (sustain off + all
   notes off + 128 noteOff) ngay sau preset apply để startup im lặng.
2) bấm GUI mở 2 cửa sổ Qin: sandbox VST2 child tự sở hữu top-level window
   -> ownsGuiWindow() + main.cpp forward OPEN_GUI control, không tạo native
   parent / không registry double-open.
3) play phát nhạc cụ sai: restore clobber — seed preset đè patch thật trong
   state file (ch3 63ba3667 -> 7f07473c) do saveStateJob chạy lúc child còn
   seed. Fix: queuePreset(waitApply=true) chờ child apply xong (presetOut
   memcmp), consume-before-apply (zero presetInLen trước khi apply), deferred
   double-load re-check trong main.cpp skip assign trùng path, watchdog
   respawn re-queue lastPreset_.
This commit is contained in:
2026-08-21 08:50:28 +07:00
parent b91e6d3875
commit a7b01d3484
7 changed files with 143 additions and 23 deletions
+9 -2
View File
@@ -313,9 +313,16 @@ float InstrumentEngineManager::recalibrate(uint32_t channel, double sampleRate,
}
if (!inst) return 1.0f;
// calibrate() probe-renders (up to ~0.9s) - never hold mu_ (audio stall).
// Flag the channel so renderAll skips it: the probe notes would otherwise
// leak into the live mix (auto-play at startup, bug 1).
{
std::lock_guard<std::mutex> lock(mu_);
if (channel < 16) calibratingCh_[channel] = true;
}
const float mk = calibrate(inst, sampleRate, blockSize);
{
std::lock_guard<std::mutex> lock(mu_);
if (channel < 16) calibratingCh_[channel] = false;
makeup_[channel] = mk;
}
return mk;
@@ -421,7 +428,7 @@ bool InstrumentEngineManager::isCrashed(uint32_t channel) const {
// khong xac dinh sau fault; xu ly tiep se fault lai.
// Called with mu_ held by the real-time dispatch.
bool InstrumentEngineManager::channelQuiet(uint32_t ch) const {
if (ch >= 16 || reloadingCh_[ch] || crashedCh_[ch]) return true;
if (ch >= 16 || reloadingCh_[ch] || crashedCh_[ch] || calibratingCh_[ch]) return true;
return false;
}
@@ -684,4 +691,4 @@ void InstrumentEngineManager::guiIdleAll() {
for (auto& kv : channels_) {
kv.second->guiIdle();
}
}
}