G0.4: save/restore preset quanh reload khi close GUI (captureState/restoreState, memorystream link truc tiep)

This commit is contained in:
2026-08-15 20:04:56 +07:00
parent 5313d85926
commit eac7f2feb8
6 changed files with 77 additions and 1 deletions
@@ -56,6 +56,10 @@ public:
// it to dedupe repeated OPEN_GUI (frontend retry spam) — re-attaching a
// view that is already attached corrupts plugins (Nexus createView→null).
virtual bool hasAttachedView() const { return false; }
// G0.4: serialize/restore the plugin preset across instance reloads
// (GUI close/reopen). Non-VST engines: no-op (nothing to save).
virtual void captureState() {}
virtual void restoreState() {}
// Real-time Audio PCM Float32 rendering loop
virtual void processAudioBlock(float* outputL, float* outputR, uint32_t numSamples) = 0;
+8
View File
@@ -9,6 +9,7 @@
#include "INativeInstrument.h"
#include <string>
#include <vector>
class Vst3Instrument : public INativeInstrument {
public:
@@ -27,6 +28,10 @@ public:
bool openGUI(void* parentWindowHandle) override;
bool reloadForGUI() override;
bool attachView(void* parentWindowHandle) override;
// G0.4: keep the preset across GUI reopen (reload() recreates the
// instance from scratch — without save/restore the plugin resets).
void captureState();
void restoreState();
void resizeView(int w, int h) override;
bool hasAttachedView() const override;
void closeGUI() override;
@@ -47,6 +52,9 @@ private:
bool hasAttachedOnce_;
bool reloading_; // guarded by InstrumentEngineManager::mu_ (set via setReloading)
uint32_t channel_ = 0;
// G0.4: serialized IComponent/IEditController state captured before reload.
std::vector<uint8_t> savedComponentState_;
std::vector<uint8_t> savedControllerState_;
};
#endif // VST3_INSTRUMENT_H