DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit db465f69b2fbe30788469b29ee9425f64ada280a
parent 090ee032746321c5557d4559d2d44d3899720a41
Author: falkTX <falktx@falktx.com>
Date:   Sat, 25 Sep 2021 11:47:35 +0100

VST3 YOLO

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdistrho/src/DistrhoPluginVST3.cpp | 76++++++++++++++++------------------------------------------------------------
Mdistrho/src/DistrhoUIVST3.cpp | 35++++++-----------------------------
2 files changed, 22 insertions(+), 89 deletions(-)

diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp @@ -1305,15 +1305,11 @@ struct v3_edit_controller_cpp : v3_funknown { }; struct dpf_edit_controller : v3_edit_controller_cpp { - std::atomic<int> refcounter; - ScopedPointer<dpf_edit_controller>* self; ScopedPointer<PluginVst3>& vst3; bool initialized; - dpf_edit_controller(ScopedPointer<dpf_edit_controller>* const s, ScopedPointer<PluginVst3>& v) - : refcounter(1), - self(s), - vst3(v), + dpf_edit_controller(ScopedPointer<PluginVst3>& v) + : vst3(v), initialized(false) { static const uint8_t* kSupportedInterfaces[] = { @@ -1342,28 +1338,9 @@ struct dpf_edit_controller : v3_edit_controller_cpp { return V3_NO_INTERFACE; }; - ref = []V3_API(void* self) -> uint32_t - { - d_stdout("dpf_edit_controller::ref => %p", self); - dpf_edit_controller* const controller = *(dpf_edit_controller**)self; - DISTRHO_SAFE_ASSERT_RETURN(controller != nullptr, 0); - - return ++controller->refcounter; - }; - - unref = []V3_API(void* self) -> uint32_t - { - d_stdout("dpf_edit_controller::unref => %p", self); - dpf_edit_controller* const controller = *(dpf_edit_controller**)self; - DISTRHO_SAFE_ASSERT_RETURN(controller != nullptr, 0); - - if (const int refcounter = --controller->refcounter) - return refcounter; - - *(dpf_edit_controller**)self = nullptr; - *controller->self = nullptr; - return 0; - }; + // there is only a single instance of this, so we don't have to care here + ref = []V3_API(void*) -> uint32_t { return 1; }; + unref = []V3_API(void*) -> uint32_t { return 0; }; // ------------------------------------------------------------------------------------------------------------ // v3_plugin_base @@ -1679,14 +1656,10 @@ struct v3_audio_processor_cpp : v3_funknown { }; struct dpf_audio_processor : v3_audio_processor_cpp { - std::atomic<int> refcounter; - ScopedPointer<dpf_audio_processor>* self; ScopedPointer<PluginVst3>& vst3; - dpf_audio_processor(ScopedPointer<dpf_audio_processor>* const s, ScopedPointer<PluginVst3>& v) - : refcounter(1), - self(s), - vst3(v) + dpf_audio_processor(ScopedPointer<PluginVst3>& v) + : vst3(v) { static const uint8_t* kSupportedInterfacesBase[] = { v3_funknown_iid, @@ -1722,28 +1695,9 @@ struct dpf_audio_processor : v3_audio_processor_cpp { return V3_NO_INTERFACE; }; - ref = []V3_API(void* self) -> uint32_t - { - d_stdout("dpf_audio_processor::ref => %p", self); - dpf_audio_processor* const processor = *(dpf_audio_processor**)self; - DISTRHO_SAFE_ASSERT_RETURN(processor != nullptr, 0); - - return ++processor->refcounter; - }; - - unref = []V3_API(void* self) -> uint32_t - { - d_stdout("dpf_audio_processor::unref => %p", self); - dpf_audio_processor* const processor = *(dpf_audio_processor**)self; - DISTRHO_SAFE_ASSERT_RETURN(processor != nullptr, 0); - - if (const int refcounter = --processor->refcounter) - return refcounter; - - *(dpf_audio_processor**)self = nullptr; - *processor->self = nullptr; - return 0; - }; + // there is only a single instance of this, so we don't have to care here + ref = []V3_API(void*) -> uint32_t { return 1; }; + unref = []V3_API(void*) -> uint32_t { return 0; }; // ------------------------------------------------------------------------------------------------------------ // v3_audio_processor @@ -1847,6 +1801,7 @@ struct dpf_audio_processor : v3_audio_processor_cpp { } }; +#if 0 // -------------------------------------------------------------------------------------------------------------------- // dpf_state_stream @@ -1886,7 +1841,7 @@ struct dpf_state_stream : v3_bstream_cpp { return V3_NO_INTERFACE; }; - // TODO + // there is only a single instance of this, so we don't have to care here ref = []V3_API(void*) -> uint32_t { return 1; }; unref = []V3_API(void*) -> uint32_t { return 0; }; @@ -1942,6 +1897,7 @@ struct dpf_state_stream : v3_bstream_cpp { }; } }; +#endif // -------------------------------------------------------------------------------------------------------------------- // dpf_component @@ -1956,7 +1912,7 @@ struct dpf_component : v3_component_cpp { ScopedPointer<dpf_component>* self; ScopedPointer<dpf_audio_processor> processor; ScopedPointer<dpf_edit_controller> controller; - ScopedPointer<dpf_state_stream> stream; + // ScopedPointer<dpf_state_stream> stream; ScopedPointer<PluginVst3> vst3; dpf_component(ScopedPointer<dpf_component>* const s) @@ -1992,7 +1948,7 @@ struct dpf_component : v3_component_cpp { if (v3_tuid_match(v3_audio_processor_iid, iid)) { if (component->processor == nullptr) - component->processor = new dpf_audio_processor(&component->processor, component->vst3); + component->processor = new dpf_audio_processor(component->vst3); *iface = &component->processor; return V3_OK; } @@ -2000,7 +1956,7 @@ struct dpf_component : v3_component_cpp { if (v3_tuid_match(v3_edit_controller_iid, iid)) { if (component->controller == nullptr) - component->controller = new dpf_edit_controller(&component->controller, component->vst3); + component->controller = new dpf_edit_controller(component->vst3); *iface = &component->controller; return V3_OK; } diff --git a/distrho/src/DistrhoUIVST3.cpp b/distrho/src/DistrhoUIVST3.cpp @@ -363,16 +363,12 @@ struct v3_plugin_view_content_scale_steinberg_cpp : v3_funknown { }; struct dpf_plugin_view_scale : v3_plugin_view_content_scale_steinberg_cpp { - std::atomic<int> refcounter; - ScopedPointer<dpf_plugin_view_scale>* self; ScopedPointer<UIVst3>& uivst3; // cached values float scaleFactor; - dpf_plugin_view_scale(ScopedPointer<dpf_plugin_view_scale>* s, ScopedPointer<UIVst3>& v) - : refcounter(1), - self(s), - uivst3(v), + dpf_plugin_view_scale(ScopedPointer<UIVst3>& v) + : uivst3(v), scaleFactor(0.0f) { static const uint8_t* kSupportedInterfaces[] = { @@ -401,28 +397,9 @@ struct dpf_plugin_view_scale : v3_plugin_view_content_scale_steinberg_cpp { return V3_NO_INTERFACE; }; - ref = []V3_API(void* self) -> uint32_t - { - d_stdout("dpf_plugin_view_scale::ref => %p", self); - dpf_plugin_view_scale* const scale = *(dpf_plugin_view_scale**)self; - DISTRHO_SAFE_ASSERT_RETURN(scale != nullptr, 0); - - return ++scale->refcounter; - }; - - unref = []V3_API(void* self) -> uint32_t - { - d_stdout("dpf_plugin_view_scale::unref => %p", self); - dpf_plugin_view_scale* const scale = *(dpf_plugin_view_scale**)self; - DISTRHO_SAFE_ASSERT_RETURN(scale != nullptr, 0); - - if (const int refcounter = --scale->refcounter) - return refcounter; - - *(dpf_plugin_view_scale**)self = nullptr; - *scale->self = nullptr; - return 0; - }; + // there is only a single instance of this, so we don't have to care here + ref = []V3_API(void*) -> uint32_t { return 1; }; + unref = []V3_API(void*) -> uint32_t { return 0; }; // ------------------------------------------------------------------------------------------------------------ // v3_plugin_view_content_scale_steinberg @@ -506,7 +483,7 @@ struct dpf_plugin_view : v3_plugin_view_cpp { if (v3_tuid_match(v3_plugin_view_content_scale_steinberg_iid, iid)) { if (view->scale == nullptr) - view->scale = new dpf_plugin_view_scale(&view->scale, view->uivst3); + view->scale = new dpf_plugin_view_scale(view->uivst3); *iface = &view->scale; return V3_OK; }