Browse Source

Some precautions, misc changes

tags/1.9.7
falkTX 10 years ago
parent
commit
11b0015713
1 changed files with 15 additions and 17 deletions
  1. +15
    -17
      source/plugin/carla-vst.cpp

+ 15
- 17
source/plugin/carla-vst.cpp View File

@@ -211,17 +211,17 @@ public:
carla_zeroStruct<NativeTimeInfo>(fTimeInfo);

// tell host we want MIDI events
masterCallback(audioMasterWantMidi);
hostCallback(audioMasterWantMidi);

// deactivate for possible changes
if (fDescriptor->deactivate != nullptr && fIsActive)
fDescriptor->deactivate(fHandle);

// check if something changed
const uint32_t bufferSize = static_cast<uint32_t>(masterCallback(audioMasterGetBlockSize));
const double sampleRate = static_cast<double>(masterCallback(audioMasterGetSampleRate));
const uint32_t bufferSize = static_cast<uint32_t>(hostCallback(audioMasterGetBlockSize));
const double sampleRate = static_cast<double>(hostCallback(audioMasterGetSampleRate));

if (fBufferSize != bufferSize)
if (bufferSize != 0 && fBufferSize != bufferSize)
{
fBufferSize = bufferSize;

@@ -229,7 +229,7 @@ public:
fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, (int32_t)value, nullptr, 0.0f);
}

if (! carla_compareFloats(fSampleRate, sampleRate))
if (sampleRate != 0.0 && ! carla_compareFloats(fSampleRate, sampleRate))
{
fSampleRate = sampleRate;

@@ -270,7 +270,7 @@ public:

// check if vst host is tracktion
carla_zeroChar(strBuf, 0xff+1);
masterCallback(audioMasterGetProductString, 0, 0, strBuf, 0.0f);
hostCallback(audioMasterGetProductString, 0, 0, strBuf, 0.0f);

const bool isTracktion(std::strcmp(strBuf, "Tracktion") == 0);

@@ -293,7 +293,7 @@ public:

for (int x=10; --x>=0;)
{
masterCallback(audioMasterIdle);
hostCallback(audioMasterIdle);
carla_msleep(25);
}
}
@@ -349,7 +349,6 @@ public:
{
// host has not activated the plugin yet, nasty!
vst_dispatcher(effMainsChanged, 0, 1, nullptr, 0.0f);
fIsActive = true;
}

if (const VstEvents* const events = (const VstEvents*)ptr)
@@ -418,12 +417,11 @@ public:
{
// host has not activated the plugin yet, nasty!
vst_dispatcher(effMainsChanged, 0, 1, nullptr, 0.0f);
fIsActive = true;
}

static const int kWantVstTimeFlags(kVstTransportPlaying|kVstPpqPosValid|kVstTempoValid|kVstTimeSigValid);

if (const VstTimeInfo* const vstTimeInfo = (const VstTimeInfo*)masterCallback(audioMasterGetTime, 0, kWantVstTimeFlags))
if (const VstTimeInfo* const vstTimeInfo = (const VstTimeInfo*)hostCallback(audioMasterGetTime, 0, kWantVstTimeFlags))
{
fTimeInfo.frame = static_cast<uint64_t>(vstTimeInfo->samplePos);
fTimeInfo.playing = (vstTimeInfo->flags & kVstTransportPlaying);
@@ -469,7 +467,7 @@ public:
fMidiEventCount = 0;

if (fMidiOutEvents.numEvents > 0)
masterCallback(audioMasterProcessEvents, 0, 0, &fMidiOutEvents, 0.0f);
hostCallback(audioMasterProcessEvents, 0, 0, &fMidiOutEvents, 0.0f);
}

protected:
@@ -558,7 +556,7 @@ protected:
break;

case NATIVE_HOST_OPCODE_HOST_IDLE:
masterCallback(audioMasterIdle);
hostCallback(audioMasterIdle);
break;
}

@@ -590,11 +588,11 @@ private:
ERect fVstRect;

// host callback
intptr_t masterCallback(const int32_t opcode,
const int32_t index = 0,
const intptr_t value = 0,
void* const ptr = nullptr,
const float opt = 0.0f)
intptr_t hostCallback(const int32_t opcode,
const int32_t index = 0,
const intptr_t value = 0,
void* const ptr = nullptr,
const float opt = 0.0f)
{
return fAudioMaster(fEffect, opcode, index, value, ptr, opt);
}


Loading…
Cancel
Save