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
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];
const uint8_t* dataExt;


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

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

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

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);
return V3_INVALID_ARG;
@@ -3087,7 +3086,6 @@ static v3_result handleUncleanComponent(ScopedPointer<dpf_component>* const comp

struct dpf_component : v3_component_cpp {
std::atomic_int refcounter;
ScopedPointer<dpf_component>* self;
ScopedPointer<dpf_audio_processor> processor;
#if DISTRHO_PLUGIN_HAS_UI
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** hostContextFromInitialize;

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

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;

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

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

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)
{
ScopedPointer<dpf_component>* const componentptr = *it;
dpf_component** const componentptr = *it;
dpf_component* const component = *componentptr;
component->cleanup();
*(component->self) = nullptr;
delete component;
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)
{
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;
DISTRHO_SAFE_ASSERT_RETURN(factory != nullptr, V3_NOT_INITIALIZED);
@@ -3606,9 +3603,9 @@ struct dpf_factory : v3_plugin_factory_cpp {
if (factory->hostContext != nullptr)
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;
}



+ 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 {
std::atomic_int refcounter;
dpf_plugin_view** const self;
ScopedPointer<dpf_ui_connection_point> connection;
ScopedPointer<dpf_plugin_view_content_scale> scale;
#ifdef DPF_VST3_USING_HOST_RUN_LOOP
@@ -823,9 +822,8 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
double sampleRate;
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),
self(s),
host(h),
instancePointer(instance),
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);

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

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

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,
(uintptr_t)parent,
scaleFactor,
@@ -1107,8 +1103,8 @@ struct dpf_plugin_view : v3_plugin_view_cpp {

const float scaleFactor = view->scale != nullptr ? view->scale->scaleFactor : 0.0f;
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->bottom = tmpUI.getHeight();
return V3_OK;
@@ -1185,7 +1181,7 @@ v3_plugin_view** dpf_plugin_view_create(v3_host_application** const host,
const double sampleRate)
{
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);
}



Loading…
Cancel
Save