Browse Source

Carla: Fix remove-all in rack mode, more RtAudio work

tags/v0.9.0
falkTX 13 years ago
parent
commit
8e2c5e18e6
7 changed files with 104 additions and 63 deletions
  1. +3
    -3
      c++/carla-backend/carla_backend_standalone.cpp
  2. +58
    -35
      c++/carla-backend/carla_engine.cpp
  3. +22
    -9
      c++/carla-backend/carla_engine.h
  4. +4
    -4
      c++/carla-backend/carla_engine_jack.cpp
  5. +1
    -1
      c++/carla-backend/carla_engine_rtaudio.cpp
  6. +6
    -1
      src/carla.py
  7. +10
    -10
      src/ui/cadence.ui

+ 3
- 3
c++/carla-backend/carla_backend_standalone.cpp View File

@@ -1268,7 +1268,7 @@ void run_tests_standalone(short idMax)
set_midi_program(id, 0);

qDebug("------------------- TEST @%i: set extra data --------------------", id);
set_custom_data(id, CarlaBackend::CUSTOM_DATA_INVALID, nullptr, nullptr);
//set_custom_data(id, CarlaBackend::CUSTOM_DATA_INVALID, nullptr, nullptr);
set_custom_data(id, CarlaBackend::CUSTOM_DATA_INVALID, "", "");
set_chunk_data(id, nullptr);
set_gui_data(id, 0, 0);
@@ -1308,7 +1308,7 @@ int main(int argc, char* argv[])
//set_option(OPTION_PROCESS_MODE, PROCESS_MODE_CONTINUOUS_RACK, nullptr);

// start engine
if (! engine_init("JACK", "carla_demo"))
if (! engine_init("PulseAudio", "carla_demo"))
{
qCritical("failed to start backend engine, reason:\n%s", get_last_error());
delete vstGui;
@@ -1350,7 +1350,7 @@ int main(int argc, char* argv[])
run_tests_standalone(id_dssi+1);

// lock
app.exec();
//app.exec();

remove_plugin(id_ladspa);
remove_plugin(id_dssi);


+ 58
- 35
c++/carla-backend/carla_engine.cpp View File

@@ -368,8 +368,9 @@ void CarlaEngine::bufferSizeChanged(uint32_t newBufferSize)
// -------------------------------------------------------------------------------------------------------------------
// Carla Engine Client

CarlaEngineClient::CarlaEngineClient(const CarlaEngineClientNativeHandle& handle_)
: handle(handle_)
CarlaEngineClient::CarlaEngineClient(const CarlaEngineType& type_, const CarlaEngineClientNativeHandle& handle_)
: type(type_),
handle(handle_)
{
qDebug("CarlaEngineClient::CarlaEngineClient()");

@@ -381,15 +382,19 @@ CarlaEngineClient::~CarlaEngineClient()
qDebug("CarlaEngineClient::~CarlaEngineClient()");
Q_ASSERT(! m_active);

#ifdef CARLA_ENGINE_JACK
# ifndef BUILD_BRIDGE
#ifndef BUILD_BRIDGE
if (carlaOptions.process_mode == PROCESS_MODE_MULTIPLE_CLIENTS)
# endif
#endif
{
if (handle.client)
jack_client_close(handle.client);
}
#ifdef CARLA_ENGINE_JACK
if (handle.jackClient)
jack_client_close(handle.jackClient);
#endif
#ifdef CARLA_ENGINE_RTAUDIO
if (handle.rtAudioPtr)
delete handle.rtAudioPtr;
#endif
}
}

void CarlaEngineClient::activate()
@@ -397,15 +402,22 @@ void CarlaEngineClient::activate()
qDebug("CarlaEngineClient::activate()");
Q_ASSERT(! m_active);

#ifdef CARLA_ENGINE_JACK
# ifndef BUILD_BRIDGE
#ifndef BUILD_BRIDGE
if (carlaOptions.process_mode == PROCESS_MODE_MULTIPLE_CLIENTS)
# endif
#endif
{
if (handle.client && ! m_active)
jack_activate(handle.client);
}
if (! m_active)
{
#ifdef CARLA_ENGINE_JACK
if (handle.jackClient)
jack_activate(handle.jackClient);
#endif
#ifdef CARLA_ENGINE_RTAUDIO
if (handle.rtAudioPtr)
handle.rtAudioPtr->startStream();
#endif
}
}

m_active = true;
}
@@ -415,15 +427,22 @@ void CarlaEngineClient::deactivate()
qDebug("CarlaEngineClient::deactivate()");
Q_ASSERT(m_active);

#ifdef CARLA_ENGINE_JACK
# ifndef BUILD_BRIDGE
#ifndef BUILD_BRIDGE
if (carlaOptions.process_mode == PROCESS_MODE_MULTIPLE_CLIENTS)
# endif
#endif
{
if (handle.client && m_active)
jack_deactivate(handle.client);
}
if (m_active)
{
#ifdef CARLA_ENGINE_JACK
if (handle.jackClient)
jack_deactivate(handle.jackClient);
#endif
#ifdef CARLA_ENGINE_RTAUDIO
if (handle.rtAudioPtr)
handle.rtAudioPtr->stopStream();
#endif
}
}

m_active = false;
}
@@ -439,12 +458,16 @@ bool CarlaEngineClient::isOk() const
{
qDebug("CarlaEngineClient::isOk()");

#ifdef CARLA_ENGINE_JACK
# ifndef BUILD_BRIDGE
#ifndef BUILD_BRIDGE
if (carlaOptions.process_mode != PROCESS_MODE_CONTINUOUS_RACK)
# endif
return bool(handle.client);
#endif
{
#ifdef CARLA_ENGINE_JACK
return bool(handle.jackClient);
// FIXME
#endif
}

return true;
}

@@ -454,7 +477,7 @@ const CarlaEngineBasePort* CarlaEngineClient::addPort(const CarlaEnginePortType

CarlaEnginePortNativeHandle portHandle;
#ifdef CARLA_ENGINE_JACK
portHandle.client = handle.client;
portHandle.jackClient = handle.jackClient;
#endif

#ifdef CARLA_ENGINE_JACK
@@ -465,11 +488,11 @@ const CarlaEngineBasePort* CarlaEngineClient::addPort(const CarlaEnginePortType
switch (type)
{
case CarlaEnginePortTypeAudio:
portHandle.port = jack_port_register(handle.client, name, JACK_DEFAULT_AUDIO_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0);
portHandle.jackPort = jack_port_register(handle.jackClient, name, JACK_DEFAULT_AUDIO_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0);
break;
case CarlaEnginePortTypeControl:
case CarlaEnginePortTypeMIDI:
portHandle.port = jack_port_register(handle.client, name, JACK_DEFAULT_MIDI_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0);
portHandle.jackPort = jack_port_register(handle.jackClient, name, JACK_DEFAULT_MIDI_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0);
break;
}
}
@@ -511,8 +534,8 @@ CarlaEngineBasePort::~CarlaEngineBasePort()
if (carlaOptions.process_mode != PROCESS_MODE_CONTINUOUS_RACK)
# endif
{
if (handle.client && handle.port)
jack_port_unregister(handle.client, handle.port);
if (handle.jackClient && handle.jackPort)
jack_port_unregister(handle.jackClient, handle.jackPort);
}
#endif
}
@@ -537,8 +560,8 @@ float* CarlaEngineAudioPort::getJackAudioBuffer(uint32_t nframes)
if (carlaOptions.process_mode == PROCESS_MODE_CONTINUOUS_RACK)
return nullptr;
# endif
Q_ASSERT(handle.port);
return (float*)jack_port_get_buffer(handle.port, nframes);
Q_ASSERT(handle.jackPort);
return (float*)jack_port_get_buffer(handle.jackPort, nframes);
}
#endif

@@ -564,9 +587,9 @@ void CarlaEngineControlPort::initBuffer(CarlaEngine* const engine)
#endif

#ifdef CARLA_ENGINE_JACK
if (handle.port)
if (handle.jackPort)
{
buffer = jack_port_get_buffer(handle.port, engine->getBufferSize());
buffer = jack_port_get_buffer(handle.jackPort, engine->getBufferSize());

if (! isInput)
jack_midi_clear_buffer(buffer);
@@ -774,9 +797,9 @@ void CarlaEngineMidiPort::initBuffer(CarlaEngine* const engine)
#endif

#ifdef CARLA_ENGINE_JACK
if (handle.port)
if (handle.jackPort)
{
buffer = jack_port_get_buffer(handle.port, engine->getBufferSize());
buffer = jack_port_get_buffer(handle.jackPort, engine->getBufferSize());

if (! isInput)
jack_midi_clear_buffer(buffer);


+ 22
- 9
c++/carla-backend/carla_engine.h View File

@@ -22,8 +22,6 @@
#include "carla_shared.h"
#include "carla_threads.h"

#include <QtCore/QMutex>

#ifdef CARLA_ENGINE_JACK
#include <jack/jack.h>
#include <jack/midiport.h>
@@ -138,22 +136,36 @@ struct CarlaTimeInfo {

struct CarlaEngineClientNativeHandle {
#ifdef CARLA_ENGINE_JACK
jack_client_t* client;
jack_client_t* jackClient;
#endif
#ifdef CARLA_ENGINE_JACK
RtAudio* rtAudioPtr;
#endif

CarlaEngineClientNativeHandle()
: client(nullptr) {}
{
#ifdef CARLA_ENGINE_JACK
jackClient = nullptr;
#endif
#ifdef CARLA_ENGINE_JACK
rtAudioPtr = nullptr;
#endif
}
};

struct CarlaEnginePortNativeHandle {
#ifdef CARLA_ENGINE_JACK
jack_client_t* client;
jack_port_t* port;
jack_client_t* jackClient;
jack_port_t* jackPort;
#endif

CarlaEnginePortNativeHandle()
: client(nullptr),
port(nullptr) {}
{
#ifdef CARLA_ENGINE_JACK
jackClient = nullptr;
jackPort = nullptr;
#endif
}
};

// -----------------------------------------------------------------------
@@ -449,7 +461,7 @@ private:
class CarlaEngineClient
{
public:
CarlaEngineClient(const CarlaEngineClientNativeHandle& handle);
CarlaEngineClient(const CarlaEngineType& type, const CarlaEngineClientNativeHandle& handle);
~CarlaEngineClient();

void activate();
@@ -462,6 +474,7 @@ public:

private:
bool m_active;
const CarlaEngineType type;
const CarlaEngineClientNativeHandle handle;
};



+ 4
- 4
c++/carla-backend/carla_engine_jack.cpp View File

@@ -240,19 +240,19 @@ CarlaEngineClient* CarlaEngineJack::addClient(CarlaPlugin* const plugin)
#ifndef BUILD_BRIDGE
if (carlaOptions.process_mode == PROCESS_MODE_SINGLE_CLIENT)
{
handle.client = client;
handle.jackClient = client;
}
else if (carlaOptions.process_mode == PROCESS_MODE_MULTIPLE_CLIENTS)
#endif
{
handle.client = jack_client_open(plugin->name(), JackNullOption, nullptr);
jack_set_process_callback(handle.client, carla_jack_process_callback_plugin, plugin);
handle.jackClient = jack_client_open(plugin->name(), JackNullOption, nullptr);
jack_set_process_callback(handle.jackClient, carla_jack_process_callback_plugin, plugin);
}
//else if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK)
//{
//}

return new CarlaEngineClient(handle);
return new CarlaEngineClient(CarlaEngineTypeJack, handle);
}

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


+ 1
- 1
c++/carla-backend/carla_engine_rtaudio.cpp View File

@@ -147,7 +147,7 @@ CarlaEngineClient* CarlaEngineRtAudio::addClient(CarlaPlugin* const plugin)
{
CarlaEngineClientNativeHandle handle;

return new CarlaEngineClient(handle);
return new CarlaEngineClient(CarlaEngineTypeRtAudio, handle);
Q_UNUSED(plugin);
}



+ 6
- 1
src/carla.py View File

@@ -1608,23 +1608,28 @@ class CarlaMainW(QMainWindow, ui_carla.Ui_CarlaMainW):

@pyqtSlot()
def slot_remove_all(self):
h = 0
for i in range(MAX_PLUGINS):
pwidget = self.m_plugin_list[i]

if not pwidget:
continue

pwidget.setId(i-h)
pwidget.edit_dialog.close()

if pwidget.gui_dialog:
pwidget.gui_dialog.close()

if Carla.Host.remove_plugin(i):
if Carla.Host.remove_plugin(i-h):
pwidget.close()
pwidget.deleteLater()
self.w_plugins.layout().removeWidget(pwidget)
self.m_plugin_list[i] = None

if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK:
h += 1

self.act_plugin_remove_all.setEnabled(False)

@pyqtSlot()


+ 10
- 10
src/ui/cadence.ui View File

@@ -983,7 +983,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_6">
@@ -1043,8 +1043,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>94</width>
<height>76</height>
<width>395</width>
<height>256</height>
</rect>
</property>
<attribute name="label">
@@ -1061,8 +1061,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>94</width>
<height>76</height>
<width>98</width>
<height>96</height>
</rect>
</property>
<attribute name="label">
@@ -1079,8 +1079,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>94</width>
<height>76</height>
<width>98</width>
<height>96</height>
</rect>
</property>
<attribute name="label">
@@ -1097,8 +1097,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>94</width>
<height>76</height>
<width>98</width>
<height>96</height>
</rect>
</property>
<attribute name="label">
@@ -1377,7 +1377,7 @@
<x>0</x>
<y>0</y>
<width>732</width>
<height>19</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">


Loading…
Cancel
Save