Browse Source

More bridge work; bridged plugins are working, kinda

tags/1.9.4
falkTX 10 years ago
parent
commit
3769d888bc
3 changed files with 72 additions and 87 deletions
  1. +6
    -6
      source/backend/engine/CarlaEngine.cpp
  2. +42
    -37
      source/backend/engine/CarlaEngineBridge.cpp
  3. +24
    -44
      source/backend/plugin/BridgePlugin.cpp

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

@@ -216,11 +216,11 @@ bool CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t

for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
{
if (fBuffer[i].type != kEngineEventTypeNull)
continue;

EngineEvent& event(fBuffer[i]);

if (event.type != kEngineEventTypeNull)
continue;

event.type = kEngineEventTypeControl;
event.time = time;
event.channel = channel;
@@ -252,11 +252,11 @@ bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t cha

for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
{
if (fBuffer[i].type != kEngineEventTypeNull)
continue;

EngineEvent& event(fBuffer[i]);

if (event.type != kEngineEventTypeNull)
continue;

event.type = kEngineEventTypeMidi;
event.time = time;
event.channel = channel;


+ 42
- 37
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -291,98 +291,97 @@ public:
case kPluginBridgeOpcodeNull:
break;

case kPluginBridgeOpcodeSetAudioPool:
{
case kPluginBridgeOpcodeSetAudioPool: {
const int64_t poolSize(fShmControl.readLong());
CARLA_SAFE_ASSERT_BREAK(poolSize > 0);
fShmAudioPool.data = (float*)carla_shm_map(fShmAudioPool.shm, size_t(poolSize));
break;
}

case kPluginBridgeOpcodeSetBufferSize:
{
case kPluginBridgeOpcodeSetBufferSize: {
const uint32_t bufferSize(fShmControl.readUInt());
bufferSizeChanged(bufferSize);
break;
}

case kPluginBridgeOpcodeSetSampleRate:
{
case kPluginBridgeOpcodeSetSampleRate: {
const float sampleRate(fShmControl.readFloat());
sampleRateChanged(sampleRate);
break;
}

case kPluginBridgeOpcodeSetParameter:
{
//const int index(fShmControl.readInt());
//const float value(fShmControl.readFloat());
case kPluginBridgeOpcodeSetParameter: {
const int32_t index(fShmControl.readInt());
const float value(fShmControl.readFloat());

CarlaPlugin* const plugin(getPluginUnchecked(0));

if (plugin != nullptr && plugin->isEnabled())
{
//plugin->setParameterValueByRealIndex(index, value, false, false, false);
//plugin->postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, value);
}
plugin->setParameterValueByRealIndex(index, value, false, false, false);

//if (index >= 0)
// plugin->postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, value);
}
break;
}

case kPluginBridgeOpcodeSetProgram:
{
//const int index(fShmControl.readInt());
case kPluginBridgeOpcodeSetProgram: {
const int32_t index(fShmControl.readInt());
CARLA_SAFE_ASSERT_BREAK(index >= 0);

CarlaPlugin* const plugin(getPluginUnchecked(0));

if (plugin != nullptr && plugin->isEnabled())
{
//plugin->setProgram(index, false, false, false);
plugin->setProgram(index, false, false, false);
//plugin->postponeRtEvent(kPluginPostRtEventProgramChange, index, 0, 0.0f);
}

break;
}

case kPluginBridgeOpcodeSetMidiProgram:
{
//const int index(fShmControl.readInt());
case kPluginBridgeOpcodeSetMidiProgram: {
const int32_t index(fShmControl.readInt());
CARLA_SAFE_ASSERT_BREAK(index >= 0);

CarlaPlugin* const plugin(getPluginUnchecked(0));

if (plugin != nullptr && plugin->isEnabled())
{
//plugin->setMidiProgram(index, false, false, false);
plugin->setMidiProgram(index, false, false, false);
//plugin->postponeRtEvent(kPluginPostRtEventMidiProgramChange, index, 0, 0.0f);
}

break;
}

case kPluginBridgeOpcodeMidiEvent:
{
//uint8_t data[4] = { 0 };
//const long time(fShmControl.readLong());
//const int dataSize(fShmControl.readInt());
case kPluginBridgeOpcodeMidiEvent: {
const int64_t time(fShmControl.readLong());
const int32_t size(fShmControl.readInt());
CARLA_SAFE_ASSERT_BREAK(time >= 0);
CARLA_SAFE_ASSERT_BREAK(size > 0 && size <= 4);

//CARLA_ASSERT_INT(dataSize >= 1 && dataSize <= 4, dataSize);
uint8_t data[size];

//for (int i=0; i < dataSize && i < 4; ++i)
// data[i] = fShmControl.readChar();
for (int32_t i=0; i < size; ++i)
data[i] = static_cast<uint8_t>(fShmControl.readChar());

//CARLA_ASSERT(pData->bufEvents.in != nullptr);
CARLA_SAFE_ASSERT_BREAK(pData->bufEvents.in != nullptr);

//if (pData->bufEvents.in != nullptr)
for (ushort i=0; i < kMaxEngineEventInternalCount; ++i)
{
// TODO
}
EngineEvent& event(pData->bufEvents.in[i]);

if (event.type != kEngineEventTypeNull)
continue;

event.fillFromMidiData(static_cast<uint8_t>(size), data);
}
break;
}

case kPluginBridgeOpcodeProcess:
{
CARLA_ASSERT(fShmAudioPool.data != nullptr);
case kPluginBridgeOpcodeProcess: {
CARLA_SAFE_ASSERT_BREAK(fShmAudioPool.data != nullptr);
CarlaPlugin* const plugin(getPluginUnchecked(0));

if (plugin != nullptr && plugin->isEnabled() && plugin->tryLock(true)) // FIXME - always lock?
@@ -402,6 +401,12 @@ public:
plugin->process(inBuffer, outBuffer, pData->bufferSize);
plugin->unlock();
}

// clear buffer
CARLA_SAFE_ASSERT_BREAK(pData->bufEvents.in != nullptr);

if (pData->bufEvents.in[0].type != kEngineEventTypeNull)
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, kMaxEngineEventInternalCount);
break;
}



+ 24
- 44
source/backend/plugin/BridgePlugin.cpp View File

@@ -1324,7 +1324,6 @@ public:
CARLA_SAFE_ASSERT_BREAK(hints >= 0);
CARLA_SAFE_ASSERT_BREAK(name != nullptr);
CARLA_SAFE_ASSERT_BREAK(unit != nullptr);

CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->param.count), index, pData->param.count);

if (index < static_cast<int32_t>(pData->param.count))
@@ -1351,7 +1350,6 @@ public:
CARLA_SAFE_ASSERT_BREAK(min < max);
CARLA_SAFE_ASSERT_BREAK(def >= min);
CARLA_SAFE_ASSERT_BREAK(def <= max);

CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->param.count), index, pData->param.count);

if (index < static_cast<int32_t>(pData->param.count))
@@ -1373,7 +1371,6 @@ public:
const float stepLarge = argv[3]->f;

CARLA_SAFE_ASSERT_BREAK(index >= 0);

CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->param.count), index, pData->param.count);

if (index < static_cast<int32_t>(pData->param.count))
@@ -1393,7 +1390,6 @@ public:

CARLA_SAFE_ASSERT_BREAK(index >= 0);
CARLA_SAFE_ASSERT_BREAK(cc >= -1 && cc < 0x5F);

CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->param.count), index, pData->param.count);

if (index < static_cast<int32_t>(pData->param.count))
@@ -1409,7 +1405,6 @@ public:

CARLA_SAFE_ASSERT_BREAK(index >= 0);
CARLA_SAFE_ASSERT_BREAK(channel >= 0 && channel < MAX_MIDI_CHANNELS);

CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->param.count), index, pData->param.count);

if (index < static_cast<int32_t>(pData->param.count))
@@ -1425,7 +1420,6 @@ public:
const float value = argv[1]->f;

CARLA_SAFE_ASSERT_BREAK(index >= 0);

CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->param.count), index, pData->param.count);

if (index < static_cast<int32_t>(pData->param.count))
@@ -1447,7 +1441,6 @@ public:
const float value = argv[1]->f;

CARLA_SAFE_ASSERT_BREAK(index >= 0);

CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->param.count), index, pData->param.count);

if (index < static_cast<int32_t>(pData->param.count))
@@ -1456,54 +1449,49 @@ public:
}

case kPluginBridgeCurrentProgram: {
#if 0
CARLA_BRIDGE_CHECK_OSC_TYPES(1, "i");

const int32_t index = argv[0]->i;

CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->prog.count), index, pData->prog.count);
CARLA_SAFE_ASSERT_BREAK(index >= -1);
CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->prog.count), index, pData->prog.count);

setProgram(index, false, true, true);
#endif
CarlaPlugin::setProgram(index, false, true, true);
break;
}

case kPluginBridgeCurrentMidiProgram: {
#if 0
CARLA_BRIDGE_CHECK_OSC_TYPES(1, "i");

const int32_t index = argv[0]->i;

CARLA_ASSERT_INT2(index < static_cast<int32_t>(pData->midiprog.count), index, pData->midiprog.count);
CARLA_SAFE_ASSERT_BREAK(index >= -1);
CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->midiprog.count), index, pData->midiprog.count);

setMidiProgram(index, false, true, true);
#endif
CarlaPlugin::setMidiProgram(index, false, true, true);
break;
}

case kPluginBridgeProgramName: {
#if 0
CARLA_BRIDGE_CHECK_OSC_TYPES(2, "is");

const int32_t index = argv[0]->i;
const char* const name = (const char*)&argv[1]->s;

CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->prog.count), index, pData->prog.count);
CARLA_ASSERT(name != nullptr);
CARLA_SAFE_ASSERT_BREAK(index >= 0);
CARLA_SAFE_ASSERT_BREAK(name != nullptr);
CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->prog.count), index, pData->prog.count);

if (index >= 0 && index < static_cast<int32_t>(pData->prog.count))
if (index < static_cast<int32_t>(pData->prog.count))
{
if (pData->prog.names[index] != nullptr)
delete[] pData->prog.names[index];

pData->prog.names[index] = carla_strdup(name);
}
#endif
break;
}

case kPluginBridgeMidiProgramData: {
#if 0
CARLA_BRIDGE_CHECK_OSC_TYPES(4, "iiis");

const int32_t index = argv[0]->i;
@@ -1511,59 +1499,51 @@ public:
const int32_t program = argv[2]->i;
const char* const name = (const char*)&argv[3]->s;

CARLA_ASSERT_INT2(index < static_cast<int32_t>(pData->midiprog.count), index, pData->midiprog.count);
CARLA_ASSERT(bank >= 0);
CARLA_ASSERT(program >= 0 && program < 128);
CARLA_ASSERT(name != nullptr);
CARLA_SAFE_ASSERT_BREAK(index >= 0);
CARLA_SAFE_ASSERT_BREAK(bank >= 0);
CARLA_SAFE_ASSERT_BREAK(program >= 0);
CARLA_SAFE_ASSERT_BREAK(name != nullptr);
CARLA_SAFE_ASSERT_INT2(index < static_cast<int32_t>(pData->midiprog.count), index, pData->midiprog.count);

if (index >= 0 && index < static_cast<int32_t>(pData->midiprog.count))
if (index < static_cast<int32_t>(pData->midiprog.count))
{
if (pData->midiprog.data[index].name != nullptr)
delete[] pData->midiprog.data[index].name;

pData->midiprog.data[index].bank = bank;
pData->midiprog.data[index].program = program;
pData->midiprog.data[index].bank = static_cast<uint32_t>(bank);
pData->midiprog.data[index].program = static_cast<uint32_t>(program);
pData->midiprog.data[index].name = carla_strdup(name);
}
#endif
break;
}

case kPluginBridgeConfigure: {
#if 0
CARLA_BRIDGE_CHECK_OSC_TYPES(2, "ss");

const char* const key = (const char*)&argv[0]->s;
const char* const value = (const char*)&argv[1]->s;

CARLA_ASSERT(key != nullptr);
CARLA_ASSERT(value != nullptr);

if (key == nullptr || value == nullptr)
break;
CARLA_SAFE_ASSERT_BREAK(key != nullptr);
CARLA_SAFE_ASSERT_BREAK(value != nullptr);

if (std::strcmp(key, CARLA_BRIDGE_MSG_HIDE_GUI) == 0)
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
else if (std::strcmp(key, CARLA_BRIDGE_MSG_SAVED) == 0)
fSaved = true;
#endif
break;
}

case kPluginBridgeSetCustomData: {
#if 0
CARLA_BRIDGE_CHECK_OSC_TYPES(3, "sss");

const char* const type = (const char*)&argv[0]->s;
const char* const key = (const char*)&argv[1]->s;
const char* const value = (const char*)&argv[2]->s;

CARLA_ASSERT(type != nullptr);
CARLA_ASSERT(key != nullptr);
CARLA_ASSERT(value != nullptr);
CARLA_SAFE_ASSERT_BREAK(type != nullptr);
CARLA_SAFE_ASSERT_BREAK(key != nullptr);
CARLA_SAFE_ASSERT_BREAK(value != nullptr);

setCustomData(type, key, value, false);
#endif
CarlaPlugin::setCustomData(type, key, value, false);
break;
}



Loading…
Cancel
Save