native_bridge: recalibrate after preset restore, reject 3rd live VST2 instance

This commit is contained in:
2026-08-20 10:50:11 +07:00
parent 4932bb88db
commit 588c0da32d
3 changed files with 81 additions and 4 deletions
@@ -276,6 +276,23 @@ bool InstrumentEngineManager::assign(uint32_t channel, InstrumentType type,
return true;
}
float InstrumentEngineManager::recalibrate(uint32_t channel, double sampleRate, uint32_t blockSize) {
INativeInstrument* inst = nullptr;
{
std::lock_guard<std::mutex> lock(mu_);
auto it = channels_.find(channel);
if (it != channels_.end()) inst = it->second.get();
}
if (!inst) return 1.0f;
// calibrate() probe-renders (up to ~0.9s) - never hold mu_ (audio stall).
const float mk = calibrate(inst, sampleRate, blockSize);
{
std::lock_guard<std::mutex> lock(mu_);
makeup_[channel] = mk;
}
return mk;
}
void InstrumentEngineManager::unload(uint32_t channel) {
if (channel >= 16) return;
// Destructor runs on the CALLER thread (VST3 terminate must run on the