Browse Source

Fix usage and crashes under multi-client mode

tags/1.9.4
falkTX 11 years ago
parent
commit
96de4d8a7e
3 changed files with 14 additions and 7 deletions
  1. +2
    -1
      source/backend/engine/CarlaEngine.cpp
  2. +6
    -3
      source/backend/engine/CarlaEngineJack.cpp
  3. +6
    -3
      source/backend/plugin/CarlaPlugin.cpp

+ 2
- 1
source/backend/engine/CarlaEngine.cpp View File

@@ -1498,7 +1498,7 @@ void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t
{ {
CarlaPlugin* const plugin = kData->plugins[i].plugin; CarlaPlugin* const plugin = kData->plugins[i].plugin;


if (plugin == nullptr || ! plugin->enabled())
if (plugin == nullptr || ! plugin->enabled() || ! plugin->tryLock())
continue; continue;


if (processed) if (processed)
@@ -1517,6 +1517,7 @@ void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t
// process // process
plugin->initBuffers(); plugin->initBuffers();
plugin->process(inBuf, outBuf, frames); plugin->process(inBuf, outBuf, frames);
plugin->unlock();


#if 0 #if 0
// if plugin has no audio inputs, add previous buffers // if plugin has no audio inputs, add previous buffers


+ 6
- 3
source/backend/engine/CarlaEngineJack.cpp View File

@@ -886,10 +886,11 @@ protected:
#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
CarlaPlugin* const plugin = getPluginUnchecked(0); CarlaPlugin* const plugin = getPluginUnchecked(0);


if (plugin && plugin->enabled())
if (plugin && plugin->enabled() && plugin->tryLock())
{ {
plugin->initBuffers(); plugin->initBuffers();
processPlugin(plugin, nframes); processPlugin(plugin, nframes);
plugin->unlock();
} }
#else #else
if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT) if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT)
@@ -898,10 +899,11 @@ protected:
{ {
CarlaPlugin* const plugin = getPluginUnchecked(i); CarlaPlugin* const plugin = getPluginUnchecked(i);


if (plugin && plugin->enabled())
if (plugin && plugin->enabled() && plugin->tryLock())
{ {
plugin->initBuffers(); plugin->initBuffers();
processPlugin(plugin, nframes); processPlugin(plugin, nframes);
plugin->unlock();
} }
} }
} }
@@ -1616,13 +1618,14 @@ private:
{ {
CarlaPlugin* const plugin = (CarlaPlugin*)arg; CarlaPlugin* const plugin = (CarlaPlugin*)arg;


if (plugin != nullptr && plugin->enabled())
if (plugin != nullptr && plugin->enabled() && plugin->tryLock())
{ {
CarlaEngineJack* const engine = (CarlaEngineJack*)CarlaPluginGetEngine(plugin); CarlaEngineJack* const engine = (CarlaEngineJack*)CarlaPluginGetEngine(plugin);


plugin->initBuffers(); plugin->initBuffers();
engine->saveTransportInfo(); engine->saveTransportInfo();
engine->processPlugin(plugin, nframes); engine->processPlugin(plugin, nframes);
plugin->unlock();
} }


return 0; return 0;


+ 6
- 3
source/backend/plugin/CarlaPlugin.cpp View File

@@ -95,6 +95,8 @@ CarlaPlugin::~CarlaPlugin()
{ {
carla_debug("CarlaPlugin::~CarlaPlugin()"); carla_debug("CarlaPlugin::~CarlaPlugin()");


kData->mutex.lock();

// Remove client and ports // Remove client and ports
if (kData->client != nullptr) if (kData->client != nullptr)
{ {
@@ -118,6 +120,7 @@ CarlaPlugin::~CarlaPlugin()
kData->prog.clear(); kData->prog.clear();
kData->midiprog.clear(); kData->midiprog.clear();
kData->custom.clear(); kData->custom.clear();
kData->mutex.unlock();


libClose(); libClose();


@@ -1899,11 +1902,10 @@ CarlaPlugin::ScopedDisabler::ScopedDisabler(CarlaPlugin* const plugin)
carla_debug("CarlaPlugin::ScopedDisabler(%p)", plugin); carla_debug("CarlaPlugin::ScopedDisabler(%p)", plugin);
CARLA_ASSERT(plugin != nullptr); CARLA_ASSERT(plugin != nullptr);


plugin->kData->mutex.lock();

if (plugin->fEnabled) if (plugin->fEnabled)
{
plugin->fEnabled = false; plugin->fEnabled = false;
plugin->kData->engine->waitForProccessEnd(plugin->id());
}


if (plugin->kData->client->isActive()) if (plugin->kData->client->isActive())
plugin->kData->client->deactivate(); plugin->kData->client->deactivate();
@@ -1915,6 +1917,7 @@ CarlaPlugin::ScopedDisabler::~ScopedDisabler()


kPlugin->fEnabled = true; kPlugin->fEnabled = true;
kPlugin->kData->client->activate(); kPlugin->kData->client->activate();
kPlugin->kData->mutex.unlock();
} }


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


Loading…
Cancel
Save