fix: bridge crash/stall when opening native VST GUI while playing

- Fix A (USER32 crash): WM_CLOSE no longer destroys the native VST
  window from the main thread (plugin editor children live on the
  channel worker thread). WM_CLOSE -> hide + closeGUI on worker;
  WM_DESTROY erases registry. LOAD_INSTRUMENT close uses closeGUI +
  SW_HIDE, waits on hasAttachedView() instead of registry erase.
- Fix B: per-process SHM name SonicForge_DAW_IPC_{pid} so stale
  bridges from old builds can never attach to a new app's ring buffer.
- Fix C (stall): opening editor for a plugin whose other channel still
  has a live instance of the same DLL (Nexus) deadlocked the audio
  loop (reload+createView on worker while audio thread processed the
  other instance). Silence same-path channels via setReloading during
  reload/attach, restore afterwards; audio resumes.
- Rebuild bridge + update install/ portable package.
This commit is contained in:
2026-08-14 14:36:34 +07:00
parent a1bbf549b7
commit 0696545ae9
6 changed files with 127 additions and 31 deletions
@@ -72,6 +72,16 @@ public:
INativeInstrument* get(uint32_t channel);
// Remove and destroy the instrument on `channel` (its destructor may call
// VST terminate — MUST run on the channel worker thread, caller's duty).
// Used by Option B: two live instances of the same plugin DLL (Nexus)
// hang createView on the second — unload the other channel's copy.
void unload(uint32_t channel);
// Path last assigned to a channel (empty if none). Windows paths are
// case-insensitive — caller must lowercase before comparing.
std::string pathOf(uint32_t channel);
// Mark a channel as rebuilding its VST instance (GUI reopen): the
// real-time loop then skips processAudioBlock for that channel so VST
// teardown never races the audio thread.
@@ -90,6 +100,7 @@ private:
mutable std::mutex mu_;
std::map<uint32_t, std::unique_ptr<INativeInstrument>> channels_;
std::map<uint32_t, std::string> paths_; // last assigned path per channel
// Per-instrument scratch so engines that overwrite (not mix) stay additive.
std::vector<float> scratchL_, scratchR_;
};