Browse Source

Small hack to allow renaming of clients (fixes #41)

tags/1.9.4
falkTX 11 years ago
parent
commit
275f5dce3f
2 changed files with 32 additions and 5 deletions
  1. +26
    -5
      source/backend/engine/CarlaEngineJack.cpp
  2. +6
    -0
      source/backend/plugin/CarlaPlugin.cpp

+ 26
- 5
source/backend/engine/CarlaEngineJack.cpp View File

@@ -764,20 +764,41 @@ public:

CARLA_ASSERT(plugin->id() == id);

bool needsReinit = (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT);
const char* name = getUniquePluginName(newName);

// JACK client rename
if (fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS)
{
CarlaEngineJackClient* const client((CarlaEngineJackClient*)CarlaPluginGetEngineClient(plugin));

if (bridge.client_rename_ptr != nullptr)
{
jack_client_t* const client = ((CarlaEngineJackClient*)CarlaPluginGetEngineClient(plugin))->kClient;
name = bridge.client_rename_ptr(client, name);
name = bridge.client_rename_ptr(client->kClient, name);
}
else
{
setLastError("Your current JACK version does not allow renaming of clients");
return nullptr;
// we should not be able to do this, jack really needs to allow client rename
needsReinit = true;

plugin->setEnabled(false);

if (client->isActive())
client->deactivate();

plugin->clearBuffers();

jackbridge_client_close(client->kClient);

jack_client_t* jclient = jackbridge_client_open(name, JackNullOption, nullptr);
name = jackbridge_get_client_name(jclient);

jackbridge_set_process_callback(jclient, carla_jack_process_callback_plugin, plugin);
# if 0
jackbridge_set_latency_callback(jclient, carla_jack_latency_callback_plugin, plugin);
# endif

std::memcpy((jack_client_t**)&client->kClient, &jclient, sizeof(jack_client_t**));
}
}

@@ -787,7 +808,7 @@ public:
// Rename
plugin->setName(name);

if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT)
if (needsReinit)
{
// reload plugin to recreate its ports
const SaveState& saveState(plugin->getSaveState());


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

@@ -1036,6 +1036,12 @@ void CarlaPlugin::setOption(const unsigned int option, const bool yesNo)
void CarlaPlugin::setEnabled(const bool yesNo)
{
fEnabled = yesNo;

if (! yesNo)
{
kData->masterMutex.lock();
kData->masterMutex.unlock();
}
}

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


Loading…
Cancel
Save