Browse Source

Carla: Force host callback pointer during VST init

tags/v0.9.0
falkTX 12 years ago
parent
commit
872bf7ba27
2 changed files with 44 additions and 18 deletions
  1. +8
    -0
      c++/carla-backend/carla_bridge.cpp
  2. +36
    -18
      c++/carla-backend/vst.cpp

+ 8
- 0
c++/carla-backend/carla_bridge.cpp View File

@@ -806,6 +806,14 @@ public:
osc_send_hide(&osc.data); osc_send_hide(&osc.data);
} }


void idleGui()
{
if (! osc.thread->isRunning())
qWarning("TESTING: Bridge has closed!");

CarlaPlugin::idleGui();
}

// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Plugin state // Plugin state




+ 36
- 18
c++/carla-backend/vst.cpp View File

@@ -63,8 +63,8 @@ public:
gui.width = 0; gui.width = 0;
gui.height = 0; gui.height = 0;


isProcessing = false;
needIdle = false;
isProcessing = false;
needIdle = false;


memset(midiEvents, 0, sizeof(VstMidiEvent)*MAX_MIDI_EVENTS*2); memset(midiEvents, 0, sizeof(VstMidiEvent)*MAX_MIDI_EVENTS*2);


@@ -1678,7 +1678,7 @@ public:
{ {
#ifdef DEBUG #ifdef DEBUG
if (opcode != audioMasterGetTime) if (opcode != audioMasterGetTime)
qDebug("VstPlugin::hostCallback(%p, %s, %i, " P_INTPTR ", %p, %f", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
qDebug("VstPlugin::hostCallback(%p, %s, %i, " P_INTPTR ", %p, %f)", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
#endif #endif


#if 0 #if 0
@@ -1714,27 +1714,40 @@ public:
} }
#endif #endif


// Check if 'resvd1' points to this plugin
// Check if 'resvd1' points to this plugin, or register ourselfs if possible
VstPlugin* self = nullptr; VstPlugin* self = nullptr;


#ifdef VESTIGE_HEADER
if (effect && effect->ptr1)
if (effect)
{ {
self = (VstPlugin*)effect->ptr1;
#ifdef VESTIGE_HEADER
if (effect->ptr1)
{
self = (VstPlugin*)effect->ptr1;
#else #else
if (effect && effect->resvd1)
{
self = (VstPlugin*)effect->resvd1;
if (effect->resvd1)
{
self = FromVstPtr<VstPlugin>(effect->resvd1);
#endif #endif
if (self->unique1 != self->unique2)
self = nullptr;
}
if (self->unique1 != self->unique2)
self = nullptr;
}


#ifdef DEBUG #ifdef DEBUG
if (self)
Q_ASSERT(self->effect == effect);
if (self)
Q_ASSERT(self->effect == effect);
#endif #endif


if (lastVstPlugin && ! self)
{
#ifdef VESTIGE_HEADER
effect->ptr1 = lastVstPlugin;
#else
effect->resvd1 = ToVstPtr(lastVstPlugin);
#endif
self = lastVstPlugin;
}
}

intptr_t ret = 0; intptr_t ret = 0;


switch (opcode) switch (opcode)
@@ -1886,7 +1899,7 @@ public:
ret = self->handleAudioMasterGetSampleRate(); ret = self->handleAudioMasterGetSampleRate();
else else
{ {
qWarning("stPlugin::hostCallback::audioMasterGetSampleRate called without valid object");
qWarning("VstPlugin::hostCallback::audioMasterGetSampleRate called without valid object");
ret = 44100; ret = 44100;
} }
break; break;
@@ -2056,7 +2069,7 @@ public:


default: default:
#ifdef DEBUG #ifdef DEBUG
qDebug("VstPlugin::hostCallback(%p, %s, %i, " P_INTPTR ", %p, %f", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
qDebug("VstPlugin::hostCallback(%p, %s, %i, " P_INTPTR ", %p, %f)", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
#endif #endif
break; break;
} }
@@ -2096,7 +2109,9 @@ public:
// --------------------------------------------------------------- // ---------------------------------------------------------------
// initialize plugin // initialize plugin


lastVstPlugin = this;
effect = vstFn(hostCallback); effect = vstFn(hostCallback);
lastVstPlugin = nullptr;


if ((! effect) || effect->magic != kEffectMagic) if ((! effect) || effect->magic != kEffectMagic)
{ {
@@ -2130,7 +2145,7 @@ public:
#ifdef VESTIGE_HEADER #ifdef VESTIGE_HEADER
effect->ptr1 = this; effect->ptr1 = this;
#else #else
effect->resvd1 = (intptr_t)this;
effect->resvd1 = ToVstPtr(this);
#endif #endif


effect->dispatcher(effect, effOpen, 0, 0, nullptr, 0.0f); effect->dispatcher(effect, effOpen, 0, 0, nullptr, 0.0f);
@@ -2225,10 +2240,13 @@ private:


bool isProcessing; bool isProcessing;
bool needIdle; bool needIdle;
static VstPlugin* lastVstPlugin;


int unique2; int unique2;
}; };


VstPlugin* VstPlugin::lastVstPlugin = nullptr;

/**@}*/ /**@}*/


CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE


Loading…
Cancel
Save