Browse Source

Cleanup

Signed-off-by: falkTX <falktx@falktx.com>
pull/338/head
falkTX 3 years ago
parent
commit
4e4d49ff70
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 21 additions and 25 deletions
  1. +3
    -0
      distrho/DistrhoPlugin.hpp
  2. +13
    -16
      distrho/src/DistrhoPluginVST3.cpp
  3. +5
    -9
      distrho/src/DistrhoUIVST3.cpp

+ 3
- 0
distrho/DistrhoPlugin.hpp View File

@@ -634,6 +634,9 @@ struct MidiEvent {
/** /**
MIDI data.@n MIDI data.@n
If size > kDataSize, dataExt is used (otherwise null). If size > kDataSize, dataExt is used (otherwise null).

When dataExt is used, the event holder is responsible for
keeping the pointer valid during the entirity of the run function.
*/ */
uint8_t data[kDataSize]; uint8_t data[kDataSize];
const uint8_t* dataExt; const uint8_t* dataExt;


+ 13
- 16
distrho/src/DistrhoPluginVST3.cpp View File

@@ -57,7 +57,6 @@ namespace std {
#include <vector> #include <vector>


/* TODO items: /* TODO items:
* - base component refcount handling
* - parameter enumeration as lists * - parameter enumeration as lists
* - hide parameter outputs? * - hide parameter outputs?
* - hide program parameter? * - hide program parameter?
@@ -3074,9 +3073,9 @@ struct dpf_audio_processor : v3_audio_processor_cpp {


struct dpf_component; struct dpf_component;


std::vector<ScopedPointer<dpf_component>*> gComponentGarbage;
std::vector<dpf_component**> gComponentGarbage;


static v3_result handleUncleanComponent(ScopedPointer<dpf_component>* const componentptr)
static v3_result handleUncleanComponent(dpf_component** const componentptr)
{ {
gComponentGarbage.push_back(componentptr); gComponentGarbage.push_back(componentptr);
return V3_INVALID_ARG; return V3_INVALID_ARG;
@@ -3087,7 +3086,6 @@ static v3_result handleUncleanComponent(ScopedPointer<dpf_component>* const comp


struct dpf_component : v3_component_cpp { struct dpf_component : v3_component_cpp {
std::atomic_int refcounter; std::atomic_int refcounter;
ScopedPointer<dpf_component>* self;
ScopedPointer<dpf_audio_processor> processor; ScopedPointer<dpf_audio_processor> processor;
#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI
ScopedPointer<dpf_dsp_connection_point> connection; // kConnectionPointComponent ScopedPointer<dpf_dsp_connection_point> connection; // kConnectionPointComponent
@@ -3097,9 +3095,8 @@ struct dpf_component : v3_component_cpp {
v3_host_application** const hostContextFromFactory; v3_host_application** const hostContextFromFactory;
v3_host_application** hostContextFromInitialize; v3_host_application** hostContextFromInitialize;


dpf_component(ScopedPointer<dpf_component>* const s, v3_host_application** const h)
dpf_component(v3_host_application** const h)
: refcounter(1), : refcounter(1),
self(s),
hostContextFromFactory(h), hostContextFromFactory(h),
hostContextFromInitialize(nullptr) hostContextFromInitialize(nullptr)
{ {
@@ -3208,7 +3205,7 @@ struct dpf_component : v3_component_cpp {


static V3_API uint32_t unref_component(void* self) static V3_API uint32_t unref_component(void* self)
{ {
ScopedPointer<dpf_component>* const componentptr = (ScopedPointer<dpf_component>*)self;
dpf_component** const componentptr = (dpf_component**)self;
dpf_component* const component = *componentptr; dpf_component* const component = *componentptr;


if (const int refcount = --component->refcounter) if (const int refcount = --component->refcounter)
@@ -3281,7 +3278,7 @@ struct dpf_component : v3_component_cpp {
if (component->hostContextFromFactory != nullptr) if (component->hostContextFromFactory != nullptr)
v3_cpp_obj_unref(component->hostContextFromFactory); v3_cpp_obj_unref(component->hostContextFromFactory);


*(component->self) = nullptr;
delete component;
delete componentptr; delete componentptr;
return 0; return 0;
} }
@@ -3517,13 +3514,13 @@ struct dpf_factory : v3_plugin_factory_cpp {


d_stdout("DPF notice: cleaning up previously undeleted components now"); d_stdout("DPF notice: cleaning up previously undeleted components now");


for (std::vector<ScopedPointer<dpf_component>*>::iterator it = gComponentGarbage.begin();
for (std::vector<dpf_component**>::iterator it = gComponentGarbage.begin();
it != gComponentGarbage.end(); ++it) it != gComponentGarbage.end(); ++it)
{ {
ScopedPointer<dpf_component>* const componentptr = *it;
dpf_component** const componentptr = *it;
dpf_component* const component = *componentptr; dpf_component* const component = *componentptr;
component->cleanup(); component->cleanup();
*(component->self) = nullptr;
delete component;
delete componentptr; delete componentptr;
} }


@@ -3595,8 +3592,8 @@ struct dpf_factory : v3_plugin_factory_cpp {
static V3_API v3_result create_instance(void* self, const v3_tuid class_id, const v3_tuid iid, void** instance) static V3_API v3_result create_instance(void* self, const v3_tuid class_id, const v3_tuid iid, void** instance)
{ {
d_stdout("dpf_factory::create_instance => %p %s %s %p", self, tuid2str(class_id), tuid2str(iid), instance); d_stdout("dpf_factory::create_instance => %p %s %s %p", self, tuid2str(class_id), tuid2str(iid), instance);
DISTRHO_SAFE_ASSERT_RETURN(v3_tuid_match(class_id, *(v3_tuid*)&dpf_tuid_class) &&
v3_tuid_match(iid, v3_component_iid), V3_NO_INTERFACE);
DISTRHO_SAFE_ASSERT_RETURN(v3_tuid_match(class_id, *(const v3_tuid*)&dpf_tuid_class) &&
v3_tuid_match(iid, v3_component_iid), V3_NO_INTERFACE);


dpf_factory* const factory = *(dpf_factory**)self; dpf_factory* const factory = *(dpf_factory**)self;
DISTRHO_SAFE_ASSERT_RETURN(factory != nullptr, V3_NOT_INITIALIZED); DISTRHO_SAFE_ASSERT_RETURN(factory != nullptr, V3_NOT_INITIALIZED);
@@ -3606,9 +3603,9 @@ struct dpf_factory : v3_plugin_factory_cpp {
if (factory->hostContext != nullptr) if (factory->hostContext != nullptr)
v3_cpp_obj_query_interface(factory->hostContext, v3_host_application_iid, &host); v3_cpp_obj_query_interface(factory->hostContext, v3_host_application_iid, &host);


ScopedPointer<dpf_component>* const componentptr = new ScopedPointer<dpf_component>;
*componentptr = new dpf_component(componentptr, host);
*instance = componentptr;
dpf_component** const componentptr = new dpf_component*;
*componentptr = new dpf_component(host);
*instance = static_cast<void*>(componentptr);
return V3_OK; return V3_OK;
} }




+ 5
- 9
distrho/src/DistrhoUIVST3.cpp View File

@@ -810,7 +810,6 @@ static const char* const kSupportedPlatforms[] = {


struct dpf_plugin_view : v3_plugin_view_cpp { struct dpf_plugin_view : v3_plugin_view_cpp {
std::atomic_int refcounter; std::atomic_int refcounter;
dpf_plugin_view** const self;
ScopedPointer<dpf_ui_connection_point> connection; ScopedPointer<dpf_ui_connection_point> connection;
ScopedPointer<dpf_plugin_view_content_scale> scale; ScopedPointer<dpf_plugin_view_content_scale> scale;
#ifdef DPF_VST3_USING_HOST_RUN_LOOP #ifdef DPF_VST3_USING_HOST_RUN_LOOP
@@ -823,9 +822,8 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
double sampleRate; double sampleRate;
v3_plugin_frame** frame; v3_plugin_frame** frame;


dpf_plugin_view(dpf_plugin_view** const s, v3_host_application** const h, void* const instance, const double sr)
dpf_plugin_view(v3_host_application** const h, void* const instance, const double sr)
: refcounter(1), : refcounter(1),
self(s),
host(h), host(h),
instancePointer(instance), instancePointer(instance),
sampleRate(sr), sampleRate(sr),
@@ -916,8 +914,6 @@ struct dpf_plugin_view : v3_plugin_view_cpp {


d_stdout("dpf_plugin_view::unref => %p | refcount is zero, deleting everything now!", self); d_stdout("dpf_plugin_view::unref => %p | refcount is zero, deleting everything now!", self);


DISTRHO_SAFE_ASSERT_RETURN(viewptr == view->self, V3_INTERNAL_ERR);

if (view->connection != nullptr && view->connection->other) if (view->connection != nullptr && view->connection->other)
v3_cpp_obj(view->connection->other)->disconnect(view->connection->other, v3_cpp_obj(view->connection->other)->disconnect(view->connection->other,
(v3_connection_point**)&view->connection); (v3_connection_point**)&view->connection);
@@ -984,7 +980,7 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
#endif #endif


const float scaleFactor = view->scale != nullptr ? view->scale->scaleFactor : 0.0f; const float scaleFactor = view->scale != nullptr ? view->scale->scaleFactor : 0.0f;
view->uivst3 = new UIVst3((v3_plugin_view**)view->self,
view->uivst3 = new UIVst3((v3_plugin_view**)self,
view->host, view->host,
(uintptr_t)parent, (uintptr_t)parent,
scaleFactor, scaleFactor,
@@ -1107,8 +1103,8 @@ struct dpf_plugin_view : v3_plugin_view_cpp {


const float scaleFactor = view->scale != nullptr ? view->scale->scaleFactor : 0.0f; const float scaleFactor = view->scale != nullptr ? view->scale->scaleFactor : 0.0f;
UIExporter tmpUI(nullptr, 0, view->sampleRate, UIExporter tmpUI(nullptr, 0, view->sampleRate,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
view->instancePointer, scaleFactor);
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
view->instancePointer, scaleFactor);
rect->right = tmpUI.getWidth(); rect->right = tmpUI.getWidth();
rect->bottom = tmpUI.getHeight(); rect->bottom = tmpUI.getHeight();
return V3_OK; return V3_OK;
@@ -1185,7 +1181,7 @@ v3_plugin_view** dpf_plugin_view_create(v3_host_application** const host,
const double sampleRate) const double sampleRate)
{ {
dpf_plugin_view** const viewptr = new dpf_plugin_view*; dpf_plugin_view** const viewptr = new dpf_plugin_view*;
*viewptr = new dpf_plugin_view(viewptr, host, instancePointer, sampleRate);
*viewptr = new dpf_plugin_view(host, instancePointer, sampleRate);
return (v3_plugin_view**)static_cast<void*>(viewptr); return (v3_plugin_view**)static_cast<void*>(viewptr);
} }




Loading…
Cancel
Save