Browse Source

Misc fixing, rtaudio engine now working nicely again

tags/1.9.4
falkTX 11 years ago
parent
commit
0937586360
2 changed files with 42 additions and 28 deletions
  1. +14
    -13
      source/backend/engine/CarlaEngineInternal.cpp
  2. +28
    -15
      source/backend/engine/CarlaEngineRtAudio.cpp

+ 14
- 13
source/backend/engine/CarlaEngineInternal.cpp View File

@@ -35,17 +35,17 @@ CARLA_BACKEND_START_NAMESPACE

static uint getCarlaRackPortIdFromName(const char* const shortname) noexcept
{
if (std::strcmp(shortname, "AudioIn1") == 0)
if (std::strcmp(shortname, "AudioIn1") == 0 || std::strcmp(shortname, "audio-in1") == 0)
return RACK_GRAPH_CARLA_PORT_AUDIO_IN1;
if (std::strcmp(shortname, "AudioIn2") == 0)
if (std::strcmp(shortname, "AudioIn2") == 0 || std::strcmp(shortname, "audio-in2") == 0)
return RACK_GRAPH_CARLA_PORT_AUDIO_IN2;
if (std::strcmp(shortname, "AudioOut1") == 0)
if (std::strcmp(shortname, "AudioOut1") == 0 || std::strcmp(shortname, "audio-out1") == 0)
return RACK_GRAPH_CARLA_PORT_AUDIO_OUT1;
if (std::strcmp(shortname, "AudioOut2") == 0)
if (std::strcmp(shortname, "AudioOut2") == 0 || std::strcmp(shortname, "audio-out2") == 0)
return RACK_GRAPH_CARLA_PORT_AUDIO_OUT2;
if (std::strcmp(shortname, "MidiIn") == 0)
if (std::strcmp(shortname, "MidiIn") == 0 || std::strcmp(shortname, "midi-in") == 0)
return RACK_GRAPH_CARLA_PORT_MIDI_IN;
if (std::strcmp(shortname, "MidiOut") == 0)
if (std::strcmp(shortname, "MidiOut") == 0 || std::strcmp(shortname, "midi-out") == 0)
return RACK_GRAPH_CARLA_PORT_MIDI_OUT;

carla_stderr("CarlaBackend::getCarlaRackPortIdFromName(%s) - invalid short name", shortname);
@@ -113,41 +113,41 @@ bool RackGraph::connect(CarlaEngine* const engine, const uint groupA, const uint
switch (carlaPort)
{
case RACK_GRAPH_CARLA_PORT_AUDIO_IN1:
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_OUT, false);
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_IN, false);
audio.mutex.lock();
makeConnection = audio.connectedIn1.append(otherPort.port);
audio.mutex.unlock();
break;

case RACK_GRAPH_CARLA_PORT_AUDIO_IN2:
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_OUT, false);
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_IN, false);
audio.mutex.lock();
makeConnection = audio.connectedIn2.append(otherPort.port);
audio.mutex.unlock();
break;

case RACK_GRAPH_CARLA_PORT_AUDIO_OUT1:
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_IN, false);
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_OUT, false);
audio.mutex.lock();
makeConnection = audio.connectedOut1.append(otherPort.port);
audio.mutex.unlock();
break;

case RACK_GRAPH_CARLA_PORT_AUDIO_OUT2:
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_IN, false);
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_OUT, false);
audio.mutex.lock();
makeConnection = audio.connectedOut2.append(otherPort.port);
audio.mutex.unlock();
break;

case RACK_GRAPH_CARLA_PORT_MIDI_IN:
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_MIDI_OUT, false);
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_MIDI_IN, false);
if (const char* const portName = midi.getName(true, otherPort.port))
makeConnection = engine->connectRackMidiInPort(portName);
break;

case RACK_GRAPH_CARLA_PORT_MIDI_OUT:
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_MIDI_IN, false);
CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_MIDI_OUT, false);
if (const char* const portName = midi.getName(false, otherPort.port))
makeConnection = engine->connectRackMidiOutPort(portName);
break;
@@ -159,7 +159,8 @@ bool RackGraph::connect(CarlaEngine* const engine, const uint groupA, const uint
return false;
}

ConnectionToId connectionToId = { ++connections.lastId, groupA, portA, groupB, portB };
ConnectionToId connectionToId;
connectionToId.setData(++connections.lastId, groupA, portA, groupB, portB);

char strBuf[STR_MAX+1];
strBuf[STR_MAX] = '\0';


+ 28
- 15
source/backend/engine/CarlaEngineRtAudio.cpp View File

@@ -369,6 +369,9 @@ public:
fMidiInEvents.clear();
//fMidiOutEvents.clear();

fMidiIns.clear();
fMidiOuts.clear();

return !hasError;
}

@@ -413,7 +416,7 @@ public:
{
RackGraph* const rack(pData->graph.rack);

rack->clear();
rack->connections.clear();

char strBuf[STR_MAX+1];
strBuf[STR_MAX] = '\0';
@@ -499,6 +502,8 @@ public:
portNameToId.setData(RACK_GRAPH_GROUP_MIDI_OUT, i, portName.c_str(), strBuf);

callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, portNameToId.group, static_cast<int>(portNameToId.port), PATCHBAY_PORT_TYPE_MIDI|PATCHBAY_PORT_IS_INPUT, 0.0f, portNameToId.name);

rack->midi.outs.append(portNameToId);
}
}

@@ -572,10 +577,10 @@ public:
const MidiPort& midiPort(it.getValue());

const uint portId(rack->midi.getPortId(true, midiPort.name));
CARLA_SAFE_ASSERT_CONTINUE(portId > 0 && portId < rack->midi.ins.count());
CARLA_SAFE_ASSERT_CONTINUE(portId < rack->midi.ins.count());

ConnectionToId connectionToId;
connectionToId.setData(++(rack->connections.lastId), RACK_GRAPH_GROUP_CARLA, RACK_GRAPH_CARLA_PORT_AUDIO_OUT2, RACK_GRAPH_GROUP_AUDIO_OUT, portId);
connectionToId.setData(++(rack->connections.lastId), RACK_GRAPH_GROUP_MIDI_IN, portId, RACK_GRAPH_GROUP_CARLA, RACK_GRAPH_CARLA_PORT_MIDI_IN);

std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupA, connectionToId.portA, connectionToId.groupB, connectionToId.portB);

@@ -589,7 +594,7 @@ public:
const MidiPort& midiPort(it.getValue());

const uint portId(rack->midi.getPortId(false, midiPort.name));
CARLA_SAFE_ASSERT_CONTINUE(portId > 0 && portId < rack->midi.outs.count());
CARLA_SAFE_ASSERT_CONTINUE(portId < rack->midi.outs.count());

ConnectionToId connectionToId;
connectionToId.setData(++(rack->connections.lastId), RACK_GRAPH_GROUP_CARLA, RACK_GRAPH_CARLA_PORT_MIDI_OUT, RACK_GRAPH_GROUP_MIDI_OUT, portId);
@@ -634,6 +639,8 @@ protected:
for (uint i=0; i < fAudioOutCount; ++i)
outBuf[i] = outsPtr+(nframes*i);

FLOAT_CLEAR(outsPtr, nframes*fAudioOutCount);

// initialize input events
carla_zeroStruct<EngineEvent>(pData->events.in, kMaxEngineEventInternalCount);

@@ -765,7 +772,13 @@ protected:
return false;
}

rtMidiIn->openPort(rtMidiPortIndex, portName);
try {
rtMidiIn->openPort(rtMidiPortIndex, portName);
}
catch(...) {
delete rtMidiIn;
return false;
};

MidiPort midiPort;
midiPort.rtmidi = rtMidiIn;
@@ -823,7 +836,6 @@ protected:
return true;
}

// FIXME - this seems to be reversed
bool disconnectRackMidiInPort(const char* const portName) override
{
CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false);
@@ -832,18 +844,19 @@ protected:
RackGraph* const rack(pData->graph.rack);
CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false);

for (LinkedList<MidiPort>::Itenerator it=fMidiOuts.begin(); it.valid(); it.next())
for (LinkedList<MidiPort>::Itenerator it=fMidiIns.begin(); it.valid(); it.next())
{
MidiPort& midiPort(it.getValue());

if (std::strcmp(midiPort.name, portName) != 0)
continue;

RtMidiOut* const midiOutPort((RtMidiOut*)midiPort.rtmidi);
RtMidiIn* const midiInPort((RtMidiIn*)midiPort.rtmidi);

delete midiOutPort;
midiInPort->cancelCallback();
delete midiInPort;

fMidiOuts.remove(it);
fMidiIns.remove(it);
return true;
}

@@ -858,19 +871,18 @@ protected:
RackGraph* const rack(pData->graph.rack);
CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false);

for (LinkedList<MidiPort>::Itenerator it=fMidiIns.begin(); it.valid(); it.next())
for (LinkedList<MidiPort>::Itenerator it=fMidiOuts.begin(); it.valid(); it.next())
{
MidiPort& midiPort(it.getValue());

if (std::strcmp(midiPort.name, portName) != 0)
continue;

RtMidiIn* const midiInPort((RtMidiIn*)midiPort.rtmidi);
RtMidiOut* const midiOutPort((RtMidiOut*)midiPort.rtmidi);

midiInPort->cancelCallback();
delete midiInPort;
delete midiOutPort;

fMidiIns.remove(it);
fMidiOuts.remove(it);
return true;
}

@@ -912,6 +924,7 @@ private:
RtLinkedList<RtMidiEvent> data;
RtLinkedList<RtMidiEvent> dataPending;

// FIXME - 32, 512 + append_sleepy? check plugin code
RtMidiEvents()
: dataPool(512, 512),
data(dataPool),


Loading…
Cancel
Save