Browse Source

Fix zynaddsubfx resource dir; cleanup

tags/1.9.4
falkTX 11 years ago
parent
commit
f9215095c7
10 changed files with 80 additions and 56 deletions
  1. +6
    -1
      source/backend/CarlaEngine.hpp
  2. +26
    -9
      source/backend/engine/CarlaEngine.cpp
  3. +6
    -6
      source/backend/engine/CarlaEngineOsc.cpp
  4. +3
    -2
      source/backend/engine/CarlaEngineThread.hpp
  5. +3
    -1
      source/backend/plugin/CarlaPluginThread.hpp
  6. +7
    -7
      source/backend/plugin/DssiPlugin.cpp
  7. +10
    -10
      source/backend/plugin/NativePlugin.cpp
  8. +15
    -15
      source/backend/plugin/VstPlugin.cpp
  9. +3
    -3
      source/backend/standalone/CarlaStandalone.cpp
  10. +1
    -2
      source/modules/carla_native/zynaddsubfx.cpp

+ 6
- 1
source/backend/CarlaEngine.hpp View File

@@ -494,7 +494,7 @@ public:
void setBufferSize(const uint32_t bufferSize);

/*!
* Direct access to the port's audio buffer.
* Direct access to the port's buffer.
*/
float* getBuffer() const noexcept
{
@@ -551,6 +551,11 @@ public:
*/
virtual const EngineEvent& getEvent(const uint32_t index);

/*!
* TODO.
*/
virtual const EngineEvent& getEventUnchecked(const uint32_t index);

/*!
* Write a control event into the buffer.\n
* Arguments are the same as in the EngineControlEvent struct.


+ 26
- 9
source/backend/engine/CarlaEngine.cpp View File

@@ -167,6 +167,11 @@ const EngineEvent& CarlaEngineEventPort::getEvent(const uint32_t index)
return fBuffer[index];
}

const EngineEvent& CarlaEngineEventPort::getEventUnchecked(const uint32_t index)
{
return fBuffer[index];
}

void CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t param, const float value)
{
CARLA_SAFE_ASSERT_RETURN(! fIsInput,);
@@ -598,13 +603,15 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons
carla_debug("CarlaEngine::addPlugin(%s, %s, \"%s\", \"%s\", \"%s\", %p)", BinaryType2Str(btype), PluginType2Str(ptype), filename, name, label, extra);

unsigned int id;
CarlaPlugin* oldPlugin = nullptr;

if (pData->nextPluginId < pData->curPluginCount)
{
id = pData->nextPluginId;
pData->nextPluginId = pData->maxPluginNumber;

CARLA_ASSERT(pData->plugins[id].plugin != nullptr);
oldPlugin = pData->plugins[id].plugin;
CARLA_ASSERT(oldPlugin != nullptr);
}
else
{
@@ -721,9 +728,17 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons
pData->plugins[id].outsPeak[0] = 0.0f;
pData->plugins[id].outsPeak[1] = 0.0f;

++pData->curPluginCount;
if (oldPlugin != nullptr)
{
delete oldPlugin;
callback(CALLBACK_RELOAD_ALL, id, 0, 0, 0.0f, plugin->getName());
}
else
{
++pData->curPluginCount;
callback(CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, plugin->getName());
}

callback(CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, plugin->getName());
return true;
}

@@ -786,12 +801,11 @@ void CarlaEngine::removeAllPlugins()

for (unsigned int i=0; i < pData->maxPluginNumber; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);

pData->plugins[i].plugin = nullptr;

if (plugin != nullptr)
if (CarlaPlugin* const plugin = pData->plugins[i].plugin)
{
pData->plugins[i].plugin = nullptr;
delete plugin;
}

// clear this plugin
pData->plugins[i].insPeak[0] = 0.0f;
@@ -953,6 +967,9 @@ const char* CarlaEngine::getUniquePluginName(const char* const name)
CARLA_ASSERT(name != nullptr);
carla_debug("CarlaEngine::getUniquePluginName(\"%s\")", name);

//static CarlaMutex m;
//const CarlaMutex::ScopedLocker sl(m);

static CarlaString sname;
sname = name;

@@ -1338,7 +1355,7 @@ void CarlaEngine::callback(const CallbackType action, const unsigned int pluginI
{
carla_debug("CarlaEngine::callback(%s, %i, %i, %i, %f, \"%s\")", CallbackType2Str(action), pluginId, value1, value2, value3, valueStr);

if (pData->callback)
if (pData->callback != nullptr)
pData->callback(pData->callbackPtr, action, pluginId, value1, value2, value3, valueStr);
}



+ 6
- 6
source/backend/engine/CarlaEngineOsc.cpp View File

@@ -37,7 +37,7 @@ extern int CarlaPluginSetOscBridgeInfo(CarlaPlugin* const plugin, const PluginBr
// -----------------------------------------------------------------------

CarlaEngineOsc::CarlaEngineOsc(CarlaEngine* const engine)
: kEngine(engine),
: fEngine(engine),
fServerTCP(nullptr),
fServerUDP(nullptr)
{
@@ -252,14 +252,14 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons
return 1;
}

if (pluginId > kEngine->getCurrentPluginCount())
if (pluginId > fEngine->getCurrentPluginCount())
{
carla_stderr("CarlaEngineOsc::handleMessage() - failed to get plugin, wrong id '%i'", pluginId);
return 1;
}

// Get plugin
CarlaPlugin* const plugin = kEngine->getPluginUnchecked(pluginId);
CarlaPlugin* const plugin = fEngine->getPluginUnchecked(pluginId);

if (plugin == nullptr || plugin->getId() != pluginId)
{
@@ -415,9 +415,9 @@ int CarlaEngineOsc::handleMsgRegister(const bool isTCP, const int argc, const lo
std::free(port);
}

for (unsigned short i=0; i < kEngine->getCurrentPluginCount(); ++i)
for (unsigned short i=0; i < fEngine->getCurrentPluginCount(); ++i)
{
CarlaPlugin* const plugin = kEngine->getPluginUnchecked(i);
CarlaPlugin* const plugin = fEngine->getPluginUnchecked(i);

if (plugin && plugin->isEnabled())
plugin->registerToOscClient();
@@ -589,7 +589,7 @@ int CarlaEngineOsc::handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1)
carla_debug("CarlaEngineOsc::handleMsgExiting()");

// TODO - check for non-UIs (dssi-vst) and set to -1 instead
kEngine->callback(CALLBACK_SHOW_GUI, plugin->getId(), 0, 0, 0.0f, nullptr);
fEngine->callback(CALLBACK_SHOW_GUI, plugin->getId(), 0, 0, 0.0f, nullptr);

// TODO
//plugin->freeOscData();


+ 3
- 2
source/backend/engine/CarlaEngineThread.hpp View File

@@ -19,7 +19,8 @@
#define CARLA_ENGINE_THREAD_HPP_INCLUDED

#include "CarlaBackend.hpp"
#include "CarlaJuceUtils.hpp"

#include "juce_core.h"

using juce::Thread;

@@ -43,7 +44,7 @@ protected:
private:
CarlaEngine* const fEngine;

CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineThread)
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineThread)
};

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


+ 3
- 1
source/backend/plugin/CarlaPluginThread.hpp View File

@@ -21,6 +21,8 @@
#include "CarlaBackend.hpp"
#include "CarlaString.hpp"

#include "juce_core.h"

using juce::Thread;

CARLA_BACKEND_START_NAMESPACE
@@ -60,7 +62,7 @@ private:
CarlaString fExtra1;
CarlaString fExtra2;

CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPluginThread)
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPluginThread)
};

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


+ 7
- 7
source/backend/plugin/DssiPlugin.cpp View File

@@ -43,7 +43,7 @@ public:
{
carla_debug("DssiPlugin::DssiPlugin(%p, %i)", engine, id);

carla_zeroStruct<snd_seq_event_t>(fMidiEvents, MAX_MIDI_EVENTS);
carla_zeroStruct<snd_seq_event_t>(fMidiEvents, kPluginMaxMidiEvents);

pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_DSSI_GUI);
}
@@ -1049,7 +1049,7 @@ public:

if (pData->extNotes.mutex.tryLock())
{
while (midiEventCount < MAX_MIDI_EVENTS && ! pData->extNotes.data.isEmpty())
while (midiEventCount < kPluginMaxMidiEvents && ! pData->extNotes.data.isEmpty())
{
const ExternalMidiNote& note(pData->extNotes.data.getFirst(true));

@@ -1207,7 +1207,7 @@ public:

if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{
if (midiEventCount >= MAX_MIDI_EVENTS)
if (midiEventCount >= kPluginMaxMidiEvents)
continue;

carla_zeroStruct<snd_seq_event_t>(fMidiEvents[midiEventCount]);
@@ -1250,7 +1250,7 @@ public:
case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
if (midiEventCount >= MAX_MIDI_EVENTS)
if (midiEventCount >= kPluginMaxMidiEvents)
continue;

carla_zeroStruct<snd_seq_event_t>(fMidiEvents[midiEventCount]);
@@ -1274,7 +1274,7 @@ public:
sendMidiAllNotesOffToCallback();
}

if (midiEventCount >= MAX_MIDI_EVENTS)
if (midiEventCount >= kPluginMaxMidiEvents)
continue;

carla_zeroStruct<snd_seq_event_t>(fMidiEvents[midiEventCount]);
@@ -1295,7 +1295,7 @@ public:

case kEngineEventTypeMidi:
{
if (midiEventCount >= MAX_MIDI_EVENTS)
if (midiEventCount >= kPluginMaxMidiEvents)
continue;

const EngineMidiEvent& midiEvent(event.midi);
@@ -1976,7 +1976,7 @@ private:
float** fAudioInBuffers;
float** fAudioOutBuffers;
float* fParamBuffers;
snd_seq_event_t fMidiEvents[MAX_MIDI_EVENTS];
snd_seq_event_t fMidiEvents[kPluginMaxMidiEvents];

static NonRtList<const char*> sMultiSynthList;



+ 10
- 10
source/backend/plugin/NativePlugin.cpp View File

@@ -220,7 +220,7 @@ public:
carla_fill<int32_t>(fCurMidiProgs, MAX_MIDI_CHANNELS, 0);
#endif

carla_zeroStruct< ::MidiEvent>(fMidiEvents, MAX_MIDI_EVENTS*2);
carla_zeroStruct< ::MidiEvent>(fMidiEvents, kPluginMaxMidiEvents*2);
carla_zeroStruct< ::TimeInfo>(fTimeInfo);

fHost.handle = this;
@@ -1329,7 +1329,7 @@ public:
}

fMidiEventCount = 0;
carla_zeroStruct< ::MidiEvent>(fMidiEvents, MAX_MIDI_EVENTS*2);
carla_zeroStruct< ::MidiEvent>(fMidiEvents, kPluginMaxMidiEvents*2);

// --------------------------------------------------------------------------------------------------------
// Check if needs reset
@@ -1410,7 +1410,7 @@ public:

if (pData->extNotes.mutex.tryLock())
{
while (fMidiEventCount < MAX_MIDI_EVENTS*2 && ! pData->extNotes.data.isEmpty())
while (fMidiEventCount < kPluginMaxMidiEvents*2 && ! pData->extNotes.data.isEmpty())
{
const ExternalMidiNote& note(pData->extNotes.data.getFirst(true));

@@ -1574,7 +1574,7 @@ public:

if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{
if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue;

fMidiEvents[fMidiEventCount].port = 0;
@@ -1623,7 +1623,7 @@ public:
case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue;

fMidiEvents[fMidiEventCount].port = 0;
@@ -1646,7 +1646,7 @@ public:
sendMidiAllNotesOffToCallback();
}

if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue;

fMidiEvents[fMidiEventCount].port = 0;
@@ -1666,7 +1666,7 @@ public:

case kEngineEventTypeMidi:
{
if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue;

const EngineMidiEvent& midiEvent(event.midi);
@@ -1749,7 +1749,7 @@ public:
}

// reverse lookup MIDI events
for (k = (MAX_MIDI_EVENTS*2)-1; k >= fMidiEventCount; --k)
for (k = (kPluginMaxMidiEvents*2)-1; k >= fMidiEventCount; --k)
{
if (fMidiEvents[k].data[0] == 0)
break;
@@ -2147,7 +2147,7 @@ protected:
}

// reverse-find first free event, and put it there
for (uint32_t i=(MAX_MIDI_EVENTS*2)-1; i > fMidiEventCount; --i)
for (uint32_t i=(kPluginMaxMidiEvents*2)-1; i > fMidiEventCount; --i)
{
if (fMidiEvents[i].data[0] == 0)
{
@@ -2466,7 +2466,7 @@ private:
float** fAudioInBuffers;
float** fAudioOutBuffers;
uint32_t fMidiEventCount;
::MidiEvent fMidiEvents[MAX_MIDI_EVENTS*2];
::MidiEvent fMidiEvents[kPluginMaxMidiEvents*2];

int32_t fCurMidiProgs[MAX_MIDI_CHANNELS];



+ 15
- 15
source/backend/plugin/VstPlugin.cpp View File

@@ -58,10 +58,10 @@ public:
{
carla_debug("VstPlugin::VstPlugin(%p, %i)", engine, id);

carla_zeroStruct<VstMidiEvent>(fMidiEvents, MAX_MIDI_EVENTS*2);
carla_zeroStruct<VstMidiEvent>(fMidiEvents, kPluginMaxMidiEvents*2);
carla_zeroStruct<VstTimeInfo_R>(fTimeInfo);

for (unsigned short i=0; i < MAX_MIDI_EVENTS*2; ++i)
for (unsigned short i=0; i < kPluginMaxMidiEvents*2; ++i)
fEvents.data[i] = (VstEvent*)&fMidiEvents[i];

pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_VST_GUI);
@@ -1006,7 +1006,7 @@ public:
}

fMidiEventCount = 0;
carla_zeroStruct<VstMidiEvent>(fMidiEvents, MAX_MIDI_EVENTS*2);
carla_zeroStruct<VstMidiEvent>(fMidiEvents, kPluginMaxMidiEvents*2);

// --------------------------------------------------------------------------------------------------------
// Check if needs reset
@@ -1124,7 +1124,7 @@ public:

if (pData->extNotes.mutex.tryLock())
{
while (fMidiEventCount < MAX_MIDI_EVENTS*2 && ! pData->extNotes.data.isEmpty())
while (fMidiEventCount < kPluginMaxMidiEvents*2 && ! pData->extNotes.data.isEmpty())
{
const ExternalMidiNote& note(pData->extNotes.data.getFirst(true));

@@ -1280,7 +1280,7 @@ public:

if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{
if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue;

carla_zeroStruct<VstMidiEvent>(fMidiEvents[fMidiEventCount]);
@@ -1316,7 +1316,7 @@ public:
case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue;

carla_zeroStruct<VstMidiEvent>(fMidiEvents[fMidiEventCount]);
@@ -1340,7 +1340,7 @@ public:
sendMidiAllNotesOffToCallback();
}

if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue;

carla_zeroStruct<VstMidiEvent>(fMidiEvents[fMidiEventCount]);
@@ -1361,7 +1361,7 @@ public:

case kEngineEventTypeMidi:
{
if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue;

const EngineMidiEvent& midiEvent(event.midi);
@@ -1427,7 +1427,7 @@ public:
if (pData->event.portOut != nullptr)
{
// reverse lookup MIDI events
for (k = (MAX_MIDI_EVENTS*2)-1; k >= fMidiEventCount; --k)
for (k = (kPluginMaxMidiEvents*2)-1; k >= fMidiEventCount; --k)
{
if (fMidiEvents[k].type == 0)
break;
@@ -1867,14 +1867,14 @@ protected:
return 0;
}

if (fMidiEventCount >= MAX_MIDI_EVENTS*2)
if (fMidiEventCount >= kPluginMaxMidiEvents*2)
return 0;


{
const VstEvents* const vstEvents((const VstEvents*)ptr);

for (int32_t i=0; i < vstEvents->numEvents && i < MAX_MIDI_EVENTS*2; ++i)
for (int32_t i=0; i < vstEvents->numEvents && i < kPluginMaxMidiEvents*2; ++i)
{
if (vstEvents->events[i] == nullptr)
break;
@@ -1885,7 +1885,7 @@ protected:
continue;

// reverse-find first free event, and put it there
for (uint32_t j=(MAX_MIDI_EVENTS*2)-1; j >= fMidiEventCount; --j)
for (uint32_t j=(kPluginMaxMidiEvents*2)-1; j >= fMidiEventCount; --j)
{
if (fMidiEvents[j].type == 0)
{
@@ -2334,13 +2334,13 @@ private:

void* fLastChunk;
uint32_t fMidiEventCount;
VstMidiEvent fMidiEvents[MAX_MIDI_EVENTS*2];
VstMidiEvent fMidiEvents[kPluginMaxMidiEvents*2];
VstTimeInfo_R fTimeInfo;

struct FixedVstEvents {
int32_t numEvents;
intptr_t reserved;
VstEvent* data[MAX_MIDI_EVENTS*2];
VstEvent* data[kPluginMaxMidiEvents*2];

FixedVstEvents()
: numEvents(0),
@@ -2350,7 +2350,7 @@ private:
#else
reserved(0)
{
carla_fill<VstEvent*>(data, MAX_MIDI_EVENTS*2, nullptr);
carla_fill<VstEvent*>(data, kPluginMaxMidiEvents*2, nullptr);
}
#endif
} fEvents;


+ 3
- 3
source/backend/standalone/CarlaStandalone.cpp View File

@@ -269,8 +269,8 @@ const CarlaNativePluginInfo* carla_get_internal_plugin_info(unsigned int interna
info.audioOuts = nativePlugin->audioOuts;
info.midiIns = nativePlugin->midiIns;
info.midiOuts = nativePlugin->midiOuts;
info.parameterIns = nativePlugin->parameterIns;
info.parameterOuts = nativePlugin->parameterOuts;
info.parameterIns = nativePlugin->paramIns;
info.parameterOuts = nativePlugin->paramOuts;

info.name = nativePlugin->name;
info.label = nativePlugin->label;
@@ -463,7 +463,7 @@ void carla_set_engine_option(CarlaOptionsType option, int value, const char* val
switch (option)
{
case CB::OPTION_PROCESS_NAME:
carla_setprocname(valueStr);
juce::Thread::setCurrentThreadName(valueStr);
break;

case CB::OPTION_PROCESS_MODE:


+ 1
- 2
source/modules/carla_native/zynaddsubfx.cpp View File

@@ -81,7 +81,6 @@ namespace Nio {
SYNTH_T* synth = nullptr;

#ifdef WANT_ZYNADDSUBFX_UI
#define PIXMAP_PATH "/resources/zynaddsubfx/"

static Fl_Tiled_Image* gModuleBackdrop = nullptr;
static CarlaString gPixmapPath;
@@ -278,7 +277,7 @@ public:
if (gPixmapPath.isEmpty())
{
gPixmapPath = host->resourceDir;
gPixmapPath += PIXMAP_PATH;
gPixmapPath += "/zynaddsubfx/";
gUiPixmapPath = gPixmapPath;
}
#endif


Loading…
Cancel
Save