G4.2: bridge-side plugin process pool — SandboxVst3Host spawns/respawns plugin_host.exe per channel, MIDI forward + audio snapshot + watchdog mute/respawn, crash isolation verified

This commit is contained in:
2026-08-16 10:52:04 +07:00
parent 7de00955d8
commit 462a5104d2
10 changed files with 287 additions and 8 deletions
+17 -5
View File
@@ -4,6 +4,7 @@
#include <fluidsynth.h>
#include <sfizz.hpp>
#include "Vst3Instrument.h"
#include "SandboxVst3Host.h"
// void* members keep fluid types out of the public header; cast here.
#define FS_SYNTH (static_cast<fluid_synth_t*>(synth))
@@ -166,7 +167,12 @@ std::unique_ptr<INativeInstrument> InstrumentEngineManager::create_instrument(In
switch (type) {
case InstrumentType::SOUNDFONT_SF2_SF3: return std::make_unique<FluidSynthInstrument>();
case InstrumentType::SFZ: return std::make_unique<SfizzInstrument>();
case InstrumentType::VST3: return std::make_unique<Vst3Instrument>();
case InstrumentType::VST3:
// G4.2: SF_SANDBOX_VST3=1 -> host the VST3 in a child
// process (plugin_host.exe). Crash kills only the child.
if (std::getenv("SF_SANDBOX_VST3"))
return std::make_unique<SandboxVst3Host>();
return std::make_unique<Vst3Instrument>();
// ponytail: VST2 host (VST2.4 SDK, Steinberg discontinued) not implemented.
case InstrumentType::VST2:
default: return nullptr;
@@ -184,10 +190,16 @@ bool InstrumentEngineManager::assign(uint32_t channel, InstrumentType type,
loaded = static_cast<FluidSynthInstrument*>(inst.get())->loadSoundFontFile(path, sampleRate);
else if (type == InstrumentType::SFZ)
loaded = static_cast<SfizzInstrument*>(inst.get())->loadSfzFile(path, sampleRate);
else if (type == InstrumentType::VST3)
loaded = static_cast<Vst3Instrument*>(inst.get())->loadPlugin(path, sampleRate);
if (type == InstrumentType::VST3)
static_cast<Vst3Instrument*>(inst.get())->setChannel(channel);
else if (type == InstrumentType::VST3) {
if (auto* v = dynamic_cast<Vst3Instrument*>(inst.get()))
loaded = v->loadPlugin(path, sampleRate);
else if (auto* s = dynamic_cast<SandboxVst3Host*>(inst.get()))
loaded = s->loadPlugin(path, sampleRate, channel);
}
if (type == InstrumentType::VST3) {
if (auto* v = dynamic_cast<Vst3Instrument*>(inst.get()))
v->setChannel(channel);
}
if (!loaded) return false;
// init() AFTER load: FluidSynth creates its synth inside loadSoundFontFile.
if (!inst->init(sampleRate, blockSize)) return false;