Browse Source

Fix the rest of the code for -Weffc++

tags/1.9.4
falkTX 10 years ago
parent
commit
017b87f811
6 changed files with 204 additions and 176 deletions
  1. +1
    -0
      source/Makefile.mk
  2. +3
    -3
      source/modules/native-plugins/Makefile
  3. +71
    -61
      source/modules/native-plugins/zynaddsubfx-fx.cpp
  4. +45
    -58
      source/modules/native-plugins/zynaddsubfx-synth.cpp
  5. +73
    -43
      source/plugin/carla-native-lv2.cpp
  6. +11
    -11
      source/utils/LinkedList.hpp

+ 1
- 0
source/Makefile.mk View File

@@ -120,6 +120,7 @@ CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
ifeq ($(LINUX),true)
CFLAGS += -isystem /opt/kxstudio/include
CXXFLAGS += -isystem /opt/kxstudio/include
CXXFLAGS += -isystem /opt/kxstudio/include/ntk
endif
ifeq ($(MACOS),true)
CFLAGS += -isystem /opt/kxstudio/include


+ 3
- 3
source/modules/native-plugins/Makefile View File

@@ -25,7 +25,7 @@ endif
# Flags for ZynAddSubFX

ifeq ($(HAVE_ZYN_DEPS),true)
ZYN_CXX_FLAGS = $(BUILD_CXX_FLAGS)
ZYN_CXX_FLAGS = $(BUILD_CXX_FLAGS) -isystem zynaddsubfx
ZYN_CXX_FLAGS += $(shell pkg-config --cflags fftw3 mxml zlib)
ifneq ($(MACOS),true)
ZYN_CXX_FLAGS += -DHAVE_SCHEDULER
@@ -168,10 +168,10 @@ zynaddsubfx-%.cpp.o: zynaddsubfx-%.cpp $(CXXDEPS) $(ZYN_UI_FILES_H)
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@

zynaddsubfx-src.cpp.o: zynaddsubfx-src.cpp $(ZYN_UI_FILES_H)
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@
$(CXX) $< $(ZYN_CXX_FLAGS) -w -c -o $@

zynaddsubfx-ui.cpp.o: zynaddsubfx-ui.cpp $(ZYN_UI_FILES_H) $(ZYN_UI_FILES_CPP)
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@
$(CXX) $< $(ZYN_CXX_FLAGS) -w -c -o $@

zynaddsubfx/UI/%.cpp: zynaddsubfx/UI/%.fl
ntk-fluid -c -o zynaddsubfx/UI/$*.cpp -h zynaddsubfx/UI/$*.h $<


+ 71
- 61
source/modules/native-plugins/zynaddsubfx-fx.cpp View File

@@ -16,14 +16,15 @@
*/

#include "CarlaNative.hpp"
#include "CarlaMathUtils.hpp"

#include "zynaddsubfx/Effects/Alienwah.h"
#include "zynaddsubfx/Effects/Chorus.h"
#include "zynaddsubfx/Effects/Distorsion.h"
#include "zynaddsubfx/Effects/DynamicFilter.h"
#include "zynaddsubfx/Effects/Echo.h"
#include "zynaddsubfx/Effects/Phaser.h"
#include "zynaddsubfx/Effects/Reverb.h"
#include "Effects/Alienwah.h"
#include "Effects/Chorus.h"
#include "Effects/Distorsion.h"
#include "Effects/DynamicFilter.h"
#include "Effects/Echo.h"
#include "Effects/Phaser.h"
#include "Effects/Reverb.h"

#include "juce_audio_basics.h"
using juce::FloatVectorOperations;
@@ -40,9 +41,10 @@ protected:
fEffect(nullptr),
efxoutl(nullptr),
efxoutr(nullptr),
fFirstInit(true)
leakDetector_FxAbstractPlugin()
{
const uint32_t bufferSize(getBufferSize());
const int bufferSize(static_cast<int>(getBufferSize()));

efxoutl = new float[bufferSize];
efxoutr = new float[bufferSize];

@@ -81,7 +83,7 @@ protected:

float getParameterValue(const uint32_t index) const final
{
return fEffect->getpar(index+2);
return static_cast<float>(fEffect->getpar(static_cast<int>(index+2)));
}

// -------------------------------------------------------------------
@@ -97,22 +99,14 @@ protected:

void setParameterValue(const uint32_t index, const float value) final
{
fFirstInit = false;
fEffect->changepar(index+2, value);
fEffect->changepar(static_cast<int>(index+2), static_cast<uchar>(carla_fixValue(0.0f, 127.0f, value)));
}

void setMidiProgram(const uint8_t, const uint32_t, const uint32_t program) final
{
fFirstInit = false;
fEffect->setpreset(program);

const float volume(float(fEffect->getpar(0))/127.0f);
hostSetVolume(volume);

const unsigned char pan(fEffect->getpar(1));
const float panning(float(pan)/63.5f-1.0f);
hostSetPanning(panning);
fEffect->setpreset(static_cast<uchar>(program));

// reset volume and pan
fEffect->changepar(0, 127);
fEffect->changepar(1, 64);
}
@@ -123,20 +117,26 @@ protected:
void activate() final
{
fEffect->cleanup();

if (fFirstInit)
{
fFirstInit = false;
hostSetDryWet(0.5f);
}
}

void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const NativeMidiEvent* const, const uint32_t) final
{
const int iframes(static_cast<int>(frames));

if (outBuffer[0] != inBuffer[0])
FloatVectorOperations::copyWithMultiply(outBuffer[0], inBuffer[0], 0.5f, iframes);
else
FloatVectorOperations::multiply(outBuffer[0], 0.5f, iframes);

if (outBuffer[1] != inBuffer[1])
FloatVectorOperations::copyWithMultiply(outBuffer[1], inBuffer[1], 0.5f, iframes);
else
FloatVectorOperations::multiply(outBuffer[1], 0.5f, iframes);

fEffect->out(Stereo<float*>(inBuffer[0], inBuffer[1]));

FloatVectorOperations::copy(outBuffer[0], efxoutl, frames);
FloatVectorOperations::copy(outBuffer[1], efxoutr, frames);
FloatVectorOperations::addWithMultiply(outBuffer[0], efxoutl, 0.5f, iframes);
FloatVectorOperations::addWithMultiply(outBuffer[1], efxoutr, 0.5f, iframes);
}

// -------------------------------------------------------------------
@@ -144,35 +144,37 @@ protected:

void bufferSizeChanged(const uint32_t bufferSize) final
{
const int ibufferSize(static_cast<int>(getBufferSize()));

delete[] efxoutl;
delete[] efxoutr;
efxoutl = new float[bufferSize];
efxoutr = new float[bufferSize];
FloatVectorOperations::clear(efxoutl, bufferSize);
FloatVectorOperations::clear(efxoutr, bufferSize);
FloatVectorOperations::clear(efxoutl, ibufferSize);
FloatVectorOperations::clear(efxoutr, ibufferSize);

doReinit(bufferSize, getSampleRate());
doReinit(getSampleRate(), bufferSize);
}

void sampleRateChanged(const double sampleRate) final
{
doReinit(getBufferSize(), sampleRate);
doReinit(sampleRate, getBufferSize());
}

void doReinit(const uint32_t bufferSize, const double sampleRate)
void doReinit(const double sampleRate, const uint32_t bufferSize)
{
float params[fParamCount];
uchar params[fParamCount];

for (uint32_t i=0; i < fParamCount; ++i)
for (int i=0, count=static_cast<int>(fParamCount); i<count; ++i)
params[i] = fEffect->getpar(i+2);

reinit(bufferSize, sampleRate);
reinit(static_cast<uint>(sampleRate), static_cast<int>(bufferSize));

for (uint32_t i=0; i < fParamCount; ++i)
for (int i=0, count=static_cast<int>(fParamCount); i<count; ++i)
fEffect->changepar(i+2, params[i]);
}

virtual void reinit(const uint32_t bufferSize, const double sampleRate) = 0;
virtual void reinit(const uint sampleRate, const int bufferSize) = 0;

// -------------------------------------------------------------------

@@ -182,7 +184,8 @@ protected:
Effect* fEffect;
float* efxoutl;
float* efxoutr;
bool fFirstInit;

CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxAbstractPlugin)
};

// -----------------------------------------------------------------------
@@ -191,9 +194,10 @@ class FxAlienWahPlugin : public FxAbstractPlugin
{
public:
FxAlienWahPlugin(const NativeHostDescriptor* const host)
: FxAbstractPlugin(host, 11, 4)
: FxAbstractPlugin(host, 11, 4),
leakDetector_FxAlienWahPlugin()
{
fEffect = new Alienwah(false, efxoutl, efxoutr, getSampleRate(), getBufferSize());
fEffect = new Alienwah(false, efxoutl, efxoutr, static_cast<uint>(getSampleRate()), static_cast<int>(getBufferSize()));
}

protected:
@@ -320,7 +324,7 @@ protected:

// -------------------------------------------------------------------

void reinit(const uint32_t bufferSize, const double sampleRate)
void reinit(const uint sampleRate, const int bufferSize) override
{
delete fEffect;
fEffect = new Alienwah(false, efxoutl, efxoutr, sampleRate, bufferSize);
@@ -336,9 +340,10 @@ class FxChorusPlugin : public FxAbstractPlugin
{
public:
FxChorusPlugin(const NativeHostDescriptor* const host)
: FxAbstractPlugin(host, 12, 10)
: FxAbstractPlugin(host, 12, 10),
leakDetector_FxChorusPlugin()
{
fEffect = new Chorus(false, efxoutl, efxoutr, getSampleRate(), getBufferSize());
fEffect = new Chorus(false, efxoutl, efxoutr, static_cast<uint>(getSampleRate()), static_cast<int>(getBufferSize()));
}

protected:
@@ -489,7 +494,7 @@ protected:

// -------------------------------------------------------------------

void reinit(const uint32_t bufferSize, const double sampleRate)
void reinit(const uint sampleRate, const int bufferSize) override
{
delete fEffect;
fEffect = new Chorus(false, efxoutl, efxoutr, sampleRate, bufferSize);
@@ -505,9 +510,10 @@ class FxDistortionPlugin : public FxAbstractPlugin
{
public:
FxDistortionPlugin(const NativeHostDescriptor* const host)
: FxAbstractPlugin(host, 11, 6)
: FxAbstractPlugin(host, 11, 6),
leakDetector_FxDistortionPlugin()
{
fEffect = new Distorsion(false, efxoutl, efxoutr, getSampleRate(), getBufferSize());
fEffect = new Distorsion(false, efxoutl, efxoutr, static_cast<uint>(getSampleRate()), static_cast<int>(getBufferSize()));
}

protected:
@@ -666,7 +672,7 @@ protected:

// -------------------------------------------------------------------

void reinit(const uint32_t bufferSize, const double sampleRate)
void reinit(const uint sampleRate, const int bufferSize) override
{
delete fEffect;
fEffect = new Distorsion(false, efxoutl, efxoutr, sampleRate, bufferSize);
@@ -682,9 +688,10 @@ class FxDynamicFilterPlugin : public FxAbstractPlugin
{
public:
FxDynamicFilterPlugin(const NativeHostDescriptor* const host)
: FxAbstractPlugin(host, 10, 5)
: FxAbstractPlugin(host, 10, 5),
leakDetector_FxDynamicFilterPlugin()
{
fEffect = new DynamicFilter(false, efxoutl, efxoutr, getSampleRate(), getBufferSize());
fEffect = new DynamicFilter(false, efxoutl, efxoutr, static_cast<uint>(getSampleRate()), static_cast<int>(getBufferSize()));
}

protected:
@@ -809,7 +816,7 @@ protected:

// -------------------------------------------------------------------

void reinit(const uint32_t bufferSize, const double sampleRate)
void reinit(const uint sampleRate, const int bufferSize) override
{
delete fEffect;
fEffect = new DynamicFilter(false, efxoutl, efxoutr, sampleRate, bufferSize);
@@ -825,9 +832,10 @@ class FxEchoPlugin : public FxAbstractPlugin
{
public:
FxEchoPlugin(const NativeHostDescriptor* const host)
: FxAbstractPlugin(host, 7, 9)
: FxAbstractPlugin(host, 7, 9),
leakDetector_FxEchoPlugin()
{
fEffect = new Echo(false, efxoutl, efxoutr, getSampleRate(), getBufferSize());
fEffect = new Echo(false, efxoutl, efxoutr, static_cast<uint>(getSampleRate()), static_cast<int>(getBufferSize()));
}

protected:
@@ -940,7 +948,7 @@ protected:

// -------------------------------------------------------------------

void reinit(const uint32_t bufferSize, const double sampleRate)
void reinit(const uint sampleRate, const int bufferSize) override
{
delete fEffect;
fEffect = new Echo(false, efxoutl, efxoutr, sampleRate, bufferSize);
@@ -956,9 +964,10 @@ class FxPhaserPlugin : public FxAbstractPlugin
{
public:
FxPhaserPlugin(const NativeHostDescriptor* const host)
: FxAbstractPlugin(host, 15, 12)
: FxAbstractPlugin(host, 15, 12),
leakDetector_FxPhaserPlugin()
{
fEffect = new Phaser(false, efxoutl, efxoutr, getSampleRate(), getBufferSize());
fEffect = new Phaser(false, efxoutl, efxoutr, static_cast<uint>(getSampleRate()), static_cast<int>(getBufferSize()));
}

protected:
@@ -1132,7 +1141,7 @@ protected:

// -------------------------------------------------------------------

void reinit(const uint32_t bufferSize, const double sampleRate)
void reinit(const uint sampleRate, const int bufferSize) override
{
delete fEffect;
fEffect = new Phaser(false, efxoutl, efxoutr, sampleRate, bufferSize);
@@ -1148,9 +1157,10 @@ class FxReverbPlugin : public FxAbstractPlugin
{
public:
FxReverbPlugin(const NativeHostDescriptor* const host)
: FxAbstractPlugin(host, 13, 13)
: FxAbstractPlugin(host, 13, 13),
leakDetector_FxReverbPlugin()
{
fEffect = new Reverb(false, efxoutl, efxoutr, getSampleRate(), getBufferSize());
fEffect = new Reverb(false, efxoutl, efxoutr, static_cast<uint>(getSampleRate()), static_cast<int>(getBufferSize()));
}

protected:
@@ -1310,7 +1320,7 @@ protected:

// -------------------------------------------------------------------

void reinit(const uint32_t bufferSize, const double sampleRate)
void reinit(const uint sampleRate, const int bufferSize) override
{
delete fEffect;
fEffect = new Reverb(false, efxoutl, efxoutr, sampleRate, bufferSize);


+ 45
- 58
source/modules/native-plugins/zynaddsubfx-synth.cpp View File

@@ -22,10 +22,10 @@

#include "CarlaMathUtils.hpp"

#include "zynaddsubfx/DSP/FFTwrapper.h"
#include "zynaddsubfx/Misc/Master.h"
#include "zynaddsubfx/Misc/Part.h"
#include "zynaddsubfx/Misc/Util.h"
#include "DSP/FFTwrapper.h"
#include "Misc/Master.h"
#include "Misc/Part.h"
#include "Misc/Util.h"

#ifdef WANT_ZYNADDSUBFX_UI
# ifdef override
@@ -33,8 +33,8 @@
# undef override
# endif

# include "zynaddsubfx/UI/common.H"
# include "zynaddsubfx/UI/MasterUI.h"
# include "UI/common.H"
# include "UI/MasterUI.h"
# include <FL/Fl_Shared_Image.H>
# include <FL/Fl_Tiled_Image.H>
# include <FL/Fl_Theme.H>
@@ -77,9 +77,9 @@ class ZynAddSubFxPrograms
{
public:
ZynAddSubFxPrograms()
: fInitiated(false)
{
}
: fInitiated(false),
fRetProgram({0, 0, nullptr}),
fPrograms() {}

~ZynAddSubFxPrograms()
{
@@ -112,7 +112,7 @@ public:
// refresh banks
master.bank.rescanforbanks();

for (uint32_t i=0, size = master.bank.banks.size(); i < size; ++i)
for (uint32_t i=0, size=static_cast<uint32_t>(master.bank.banks.size()); i<size; ++i)
{
if (master.bank.banks[i].dir.empty())
continue;
@@ -165,12 +165,12 @@ public:
}
}

uint32_t count()
uint32_t count() const noexcept
{
return fPrograms.count();
return static_cast<uint32_t>(fPrograms.count());
}

const NativeMidiProgram* getInfo(const uint32_t index)
const NativeMidiProgram* getInfo(const uint32_t index) const noexcept
{
if (index >= fPrograms.count())
return nullptr;
@@ -191,12 +191,12 @@ private:
uint32_t prog;
const char* name;

ProgramInfo(uint32_t bank_, uint32_t prog_, const char* name_)
ProgramInfo(uint32_t bank_, uint32_t prog_, const char* name_) noexcept
: bank(bank_),
prog(prog_),
name(carla_strdup(name_)) {}
name(carla_strdup_safe(name_)) {}

~ProgramInfo()
~ProgramInfo() noexcept
{
if (name != nullptr)
{
@@ -215,9 +215,10 @@ private:
};

bool fInitiated;
NativeMidiProgram fRetProgram;
mutable NativeMidiProgram fRetProgram;
LinkedList<const ProgramInfo*> fPrograms;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPY_CLASS(ZynAddSubFxPrograms)
};

@@ -292,8 +293,8 @@ public:
}

synth = new SYNTH_T();
synth->buffersize = host->get_buffer_size(host->handle);
synth->samplerate = host->get_sample_rate(host->handle);
synth->buffersize = static_cast<int>(host->get_buffer_size(host->handle));
synth->samplerate = static_cast<uint>(host->get_sample_rate(host->handle));

if (synth->buffersize > 32)
synth->buffersize = 32;
@@ -302,14 +303,14 @@ public:

config.init();
config.cfg.SoundBufferSize = synth->buffersize;
config.cfg.SampleRate = synth->samplerate;
config.cfg.SampleRate = static_cast<int>(synth->samplerate);
config.cfg.GzipCompression = 0;

sprng(std::time(nullptr));
sprng(static_cast<prng_t>(std::time(nullptr)));

denormalkillbuf = new float[synth->buffersize];
for (int i=0; i < synth->buffersize; ++i)
denormalkillbuf[i] = (RND - 0.5f) * 1e-16;
denormalkillbuf[i] = (RND - 0.5f) * 1e-16f;

Master::getInstance();
}
@@ -326,6 +327,7 @@ public:
private:
int fCount;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPY_CLASS(ZynAddSubFxInstanceCount)
};

@@ -536,6 +538,9 @@ private:
volatile uint8_t fNextChannel;
volatile uint32_t fNextBank;
volatile uint32_t fNextProgram;

CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPY_CLASS(ZynAddSubFxThread)
};

// -----------------------------------------------------------------------
@@ -546,9 +551,10 @@ public:
ZynAddSubFxPlugin(const NativeHostDescriptor* const host)
: NativePluginClass(host),
fMaster(new Master()),
fSampleRate(getSampleRate()),
fSampleRate(static_cast<uint>(getSampleRate())),
fIsActive(false),
fThread(fMaster, host)
fThread(fMaster, host),
leakDetector_ZynAddSubFxPlugin()
{
fThread.startThread();

@@ -556,11 +562,6 @@ public:
fMaster->partonoff(i, 1);

sPrograms.init();

#if 0
// create instance if needed
getGlobalMutex();
#endif
}

~ZynAddSubFxPlugin() override
@@ -643,46 +644,42 @@ protected:
{
if (pthread_mutex_trylock(&fMaster->mutex) != 0)
{
FloatVectorOperations::clear(outBuffer[0], frames);
FloatVectorOperations::clear(outBuffer[1], frames);
FloatVectorOperations::clear(outBuffer[0], static_cast<int>(frames));
FloatVectorOperations::clear(outBuffer[1], static_cast<int>(frames));
return;
}

#if 0
const CarlaMutexLocker csm(getGlobalMutex());
#endif

for (uint32_t i=0; i < midiEventCount; ++i)
{
const NativeMidiEvent* const midiEvent(&midiEvents[i]);

const uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent->data);
const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(midiEvent->data);
const char channel = MIDI_GET_CHANNEL_FROM_DATA(midiEvent->data);

if (MIDI_IS_STATUS_NOTE_OFF(status))
{
const uint8_t note = midiEvent->data[1];
const char note = static_cast<char>(midiEvent->data[1]);

fMaster->noteOff(channel, note);
}
else if (MIDI_IS_STATUS_NOTE_ON(status))
{
const uint8_t note = midiEvent->data[1];
const uint8_t velo = midiEvent->data[2];
const char note = static_cast<char>(midiEvent->data[1]);
const char velo = static_cast<char>(midiEvent->data[2]);

fMaster->noteOn(channel, note, velo);
}
else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status))
{
const uint8_t note = midiEvent->data[1];
const uint8_t pressure = midiEvent->data[2];
const char note = static_cast<char>(midiEvent->data[1]);
const char pressure = static_cast<char>(midiEvent->data[2]);

fMaster->polyphonicAftertouch(channel, note, pressure);
}
else if (MIDI_IS_STATUS_CONTROL_CHANGE(status))
{
const uint8_t control = midiEvent->data[1];
const uint8_t value = midiEvent->data[2];
const int control = midiEvent->data[1];
const int value = midiEvent->data[2];

fMaster->setController(channel, control, value);
}
@@ -729,7 +726,7 @@ protected:
void setState(const char* const data) override
{
fThread.stopLoadProgramLater();
fMaster->putalldata((char*)data, 0);
fMaster->putalldata(const_cast<char*>(data), 0);
fMaster->applyparameters(true);
}

@@ -747,7 +744,7 @@ protected:

void sampleRateChanged(const double sampleRate) final
{
fSampleRate = sampleRate;
fSampleRate = static_cast<uint>(sampleRate);
deleteMaster();
sInstanceCount.maybeReinit(getHostHandle());
initMaster();
@@ -784,22 +781,12 @@ protected:
// -------------------------------------------------------------------

private:
Master* fMaster;
unsigned fSampleRate;
bool fIsActive;
Master* fMaster;
uint fSampleRate;
bool fIsActive;

ZynAddSubFxThread fThread;

#if 0
// -------------------------------------------------------------------

static CarlaMutex& getGlobalMutex() noexcept
{
static CarlaMutex m;
return m;
}
#endif

// -------------------------------------------------------------------

public:


+ 73
- 43
source/plugin/carla-native-lv2.cpp View File

@@ -39,27 +39,67 @@ using juce::FloatVectorOperations;

#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
# include "juce_gui_basics.h"
static juce::Array<void*> gActivePlugins;
using juce::ScopedJuceInitialiser_GUI;
using juce::SharedResourcePointer;
#endif

// -----------------------------------------------------------------------
// -Weffc++ compat ext widget

extern "C" {

typedef struct _LV2_External_UI_Widget_Compat {
void (*run )(struct _LV2_External_UI_Widget_Compat*);
void (*show)(struct _LV2_External_UI_Widget_Compat*);
void (*hide)(struct _LV2_External_UI_Widget_Compat*);

_LV2_External_UI_Widget_Compat()
: run(nullptr), show(nullptr), hide(nullptr) {}

} LV2_External_UI_Widget_Compat;

}

// -----------------------------------------------------------------------
// LV2 descriptor functions

class NativePlugin : public LV2_External_UI_Widget
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Weffc++"
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Weffc++"
#endif
class NativePlugin : public LV2_External_UI_Widget_Compat
{
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
# pragma GCC diagnostic pop
#endif
public:
static const uint32_t kMaxMidiEvents = 512;

NativePlugin(const NativePluginDescriptor* const desc, const double sampleRate, const char* const bundlePath, const LV2_Feature* const* features)
: fHandle(nullptr),
fHost(),
fDescriptor(desc),
fProgramDesc({0, 0, nullptr}),
fMidiEventCount(0),
fTimeInfo(),
fIsProcessing(false),
fVolume(1.0f),
fDryWet(1.0f),
fBufferSize(0),
fSampleRate(sampleRate),
fUridMap(nullptr)
fUridMap(nullptr),
fURIs(),
fUI(),
fPorts(),
#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
sJuceGUI(),
#endif
leakDetector_NativePlugin()
{
run = extui_run;
show = extui_show;
@@ -89,12 +129,6 @@ public:
fHost.ui_save_file = host_ui_save_file;
fHost.dispatcher = host_dispatcher;

#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
if (gActivePlugins.size() == 0)
juce::initialiseJuce_GUI();
gActivePlugins.add(this);
#endif

const LV2_Options_Option* options = nullptr;
const LV2_URID_Map* uridMap = nullptr;
const LV2_URID_Unmap* uridUnmap = nullptr;
@@ -160,14 +194,6 @@ public:
delete[] fHost.resourceDir;
fHost.resourceDir = nullptr;
}

#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
jassert(gActivePlugins.contains(this));
gActivePlugins.removeFirstMatchingValue(this);

if (gActivePlugins.size() == 0)
juce::shutdownJuce_GUI();
#endif
}

bool init()
@@ -194,7 +220,7 @@ public:
carla_zeroStruct<NativeTimeInfo>(fTimeInfo);

fPorts.init(fDescriptor, fHandle);
fUris.map(fUridMap);
fURIs.map(fUridMap);

return true;
}
@@ -271,7 +297,7 @@ public:
if (event->time.frames >= frames)
break;

if (event->body.type == fUris.midiEvent)
if (event->body.type == fURIs.midiEvent)
{
if (fMidiEventCount >= kMaxMidiEvents*2)
continue;
@@ -289,11 +315,11 @@ public:
continue;
}

if (event->body.type == fUris.atomBlank)
if (event->body.type == fURIs.atomBlank)
{
const LV2_Atom_Object* const obj((const LV2_Atom_Object*)&event->body);

if (obj->body.otype != fUris.timePos)
if (obj->body.otype != fURIs.timePos)
continue;

LV2_Atom* bar = nullptr;
@@ -305,32 +331,32 @@ public:
LV2_Atom* speed = nullptr;

lv2_atom_object_get(obj,
fUris.timeBar, &bar,
fUris.timeBarBeat, &barBeat,
fUris.timeBeatsPerBar, &beatsPerBar,
fUris.timeBeatsPerMinute, &bpm,
fUris.timeBeatUnit, &beatUnit,
fUris.timeFrame, &frame,
fUris.timeSpeed, &speed,
fURIs.timeBar, &bar,
fURIs.timeBarBeat, &barBeat,
fURIs.timeBeatsPerBar, &beatsPerBar,
fURIs.timeBeatsPerMinute, &bpm,
fURIs.timeBeatUnit, &beatUnit,
fURIs.timeFrame, &frame,
fURIs.timeSpeed, &speed,
nullptr);

if (bpm != nullptr && bpm->type == fUris.atomFloat)
if (bpm != nullptr && bpm->type == fURIs.atomFloat)
{
fTimeInfo.bbt.beatsPerMinute = ((LV2_Atom_Float*)bpm)->body;
fTimeInfo.bbt.valid = true;
}

if (beatsPerBar != nullptr && beatsPerBar->type == fUris.atomFloat)
if (beatsPerBar != nullptr && beatsPerBar->type == fURIs.atomFloat)
{
float beatsPerBarValue = ((LV2_Atom_Float*)beatsPerBar)->body;
fTimeInfo.bbt.beatsPerBar = beatsPerBarValue;

if (bar != nullptr && bar->type == fUris.atomLong)
if (bar != nullptr && bar->type == fURIs.atomLong)
{
//float barValue = ((LV2_Atom_Long*)bar)->body;
//curPosInfo.ppqPositionOfLastBarStart = barValue * beatsPerBarValue;

if (barBeat != nullptr && barBeat->type == fUris.atomFloat)
if (barBeat != nullptr && barBeat->type == fURIs.atomFloat)
{
//float barBeatValue = ((LV2_Atom_Float*)barBeat)->body;
//curPosInfo.ppqPosition = curPosInfo.ppqPositionOfLastBarStart + barBeatValue;
@@ -338,10 +364,10 @@ public:
}
}

if (beatUnit != nullptr && beatUnit->type == fUris.atomFloat)
if (beatUnit != nullptr && beatUnit->type == fURIs.atomFloat)
fTimeInfo.bbt.beatType = ((LV2_Atom_Float*)beatUnit)->body;

if (frame != nullptr && frame->type == fUris.atomLong)
if (frame != nullptr && frame->type == fURIs.atomLong)
{
const int64_t value(((LV2_Atom_Long*)frame)->body);
CARLA_SAFE_ASSERT_CONTINUE(value >= 0);
@@ -349,7 +375,7 @@ public:
fTimeInfo.frame = static_cast<uint64_t>(value);
}

if (speed != nullptr && speed->type == fUris.atomFloat)
if (speed != nullptr && speed->type == fURIs.atomFloat)
fTimeInfo.playing = ((LV2_Atom_Float*)speed)->body == 1.0f;

continue;
@@ -364,7 +390,7 @@ public:

if (event == nullptr)
continue;
if (event->body.type != fUris.midiEvent)
if (event->body.type != fURIs.midiEvent)
continue;
if (event->body.size > 4)
continue;
@@ -498,7 +524,7 @@ public:

if (char* const state = fDescriptor->get_state(fHandle))
{
store(handle, fUridMap->map(fUridMap->handle, "http://kxstudio.sf.net/ns/carla/chunk"), state, std::strlen(state), fUris.atomString, LV2_STATE_IS_POD|LV2_STATE_IS_PORTABLE);
store(handle, fUridMap->map(fUridMap->handle, "http://kxstudio.sf.net/ns/carla/chunk"), state, std::strlen(state), fURIs.atomString, LV2_STATE_IS_POD|LV2_STATE_IS_PORTABLE);
std::free(state);
return LV2_STATE_SUCCESS;
}
@@ -521,7 +547,7 @@ public:
return LV2_STATE_ERR_UNKNOWN;
if (data == nullptr)
return LV2_STATE_ERR_UNKNOWN;
if (type != fUris.atomString)
if (type != fURIs.atomString)
return LV2_STATE_ERR_BAD_TYPE;

fDescriptor->set_state(fHandle, (const char*)data);
@@ -889,7 +915,7 @@ private:
timeBeatsPerBar = uridMap->map(uridMap->handle, LV2_TIME__beatsPerBar);
timeBeatsPerMinute = uridMap->map(uridMap->handle, LV2_TIME__beatsPerMinute);
}
} fUris;
} fURIs;

struct UI {
const LV2_External_UI_Host* host;
@@ -1092,21 +1118,25 @@ private:
CARLA_DECLARE_NON_COPY_STRUCT(Ports);
} fPorts;

#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
SharedResourcePointer<ScopedJuceInitialiser_GUI> sJuceGUI;
#endif

// -------------------------------------------------------------------

#define handlePtr ((NativePlugin*)_this_)
#define handlePtr ((NativePlugin*)self)

static void extui_run(LV2_External_UI_Widget* _this_)
static void extui_run(LV2_External_UI_Widget_Compat* self)
{
handlePtr->handleUiRun();
}

static void extui_show(LV2_External_UI_Widget* _this_)
static void extui_show(LV2_External_UI_Widget_Compat* self)
{
handlePtr->handleUiShow();
}

static void extui_hide(LV2_External_UI_Widget* _this_)
static void extui_hide(LV2_External_UI_Widget_Compat* self)
{
handlePtr->handleUiHide();
}


+ 11
- 11
source/utils/LinkedList.hpp View File

@@ -24,7 +24,7 @@
// Define list_entry and list_entry_const

#ifndef offsetof
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
# define offsetof(TYPE, MEMBER) ((std::size_t) &((TYPE *)0)->MEMBER)
#endif

#if (defined(__GNUC__) || defined(__clang__)) && ! defined(__STRICT_ANSI__)
@@ -144,7 +144,7 @@ public:
_init();
}

size_t count() const noexcept
std::size_t count() const noexcept
{
return fCount;
}
@@ -174,11 +174,11 @@ public:
return _add(value, false, it.fEntry->prev);
}

const T& getAt(const size_t index, const T& fallback) const noexcept
const T& getAt(const std::size_t index, const T& fallback) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fCount > 0 && index < fCount, fallback);

size_t i = 0;
std::size_t i = 0;
ListHead* entry;
ListHead* entry2;

@@ -193,11 +193,11 @@ public:
return fallback;
}

T& getAt(const size_t index, T& fallback) const noexcept
T& getAt(const std::size_t index, T& fallback) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fCount > 0 && index < fCount, fallback);

size_t i = 0;
std::size_t i = 0;
ListHead* entry;
ListHead* entry2;

@@ -212,11 +212,11 @@ public:
return fallback;
}

T getAt(const size_t index, T& fallback, const bool removeObj) noexcept
T getAt(const std::size_t index, T& fallback, const bool removeObj) noexcept
{
CARLA_SAFE_ASSERT_RETURN(fCount > 0 && index < fCount, fallback);

size_t i = 0;
std::size_t i = 0;
ListHead* entry;
ListHead* entry2;

@@ -342,10 +342,10 @@ public:
}

protected:
const size_t kDataSize;
const std::size_t kDataSize;

size_t fCount;
ListHead fQueue;
std::size_t fCount;
ListHead fQueue;

virtual Data* _allocate() noexcept = 0;
virtual void _deallocate(Data* const dataPtr) noexcept = 0;


Loading…
Cancel
Save