Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

716 lines
20KB

  1. /*
  2. * Carla Bridge Plugin
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaBridgeClient.hpp"
  18. #include "CarlaEngine.hpp"
  19. #include "CarlaPlugin.hpp"
  20. #include "CarlaHost.h"
  21. #include "CarlaBackendUtils.hpp"
  22. #include "CarlaBridgeUtils.hpp"
  23. #include "CarlaMIDI.h"
  24. #ifdef CARLA_OS_UNIX
  25. # include <signal.h>
  26. #endif
  27. #ifdef HAVE_JUCE
  28. # include "juce_gui_basics.h"
  29. using juce::JUCEApplication;
  30. using juce::JUCEApplicationBase;
  31. using juce::String;
  32. using juce::Timer;
  33. #endif
  34. // -------------------------------------------------------------------------
  35. static bool gIsInitiated = false;
  36. static volatile bool gCloseNow = false;
  37. static volatile bool gSaveNow = false;
  38. #ifdef CARLA_OS_WIN
  39. static BOOL WINAPI winSignalHandler(DWORD dwCtrlType)
  40. {
  41. if (dwCtrlType == CTRL_C_EVENT)
  42. {
  43. gCloseNow = true;
  44. return TRUE;
  45. }
  46. return FALSE;
  47. }
  48. #elif defined(CARLA_OS_LINUX)
  49. static void closeSignalHandler(int)
  50. {
  51. gCloseNow = true;
  52. }
  53. static void saveSignalHandler(int)
  54. {
  55. gSaveNow = true;
  56. }
  57. #endif
  58. static void initSignalHandler()
  59. {
  60. #ifdef CARLA_OS_WIN
  61. SetConsoleCtrlHandler(winSignalHandler, TRUE);
  62. #elif defined(CARLA_OS_LINUX)
  63. struct sigaction sint;
  64. struct sigaction sterm;
  65. struct sigaction susr1;
  66. sint.sa_handler = closeSignalHandler;
  67. sint.sa_flags = SA_RESTART;
  68. sint.sa_restorer = nullptr;
  69. sigemptyset(&sint.sa_mask);
  70. sigaction(SIGINT, &sint, nullptr);
  71. sterm.sa_handler = closeSignalHandler;
  72. sterm.sa_flags = SA_RESTART;
  73. sterm.sa_restorer = nullptr;
  74. sigemptyset(&sterm.sa_mask);
  75. sigaction(SIGTERM, &sterm, nullptr);
  76. susr1.sa_handler = saveSignalHandler;
  77. susr1.sa_flags = SA_RESTART;
  78. susr1.sa_restorer = nullptr;
  79. sigemptyset(&susr1.sa_mask);
  80. sigaction(SIGUSR1, &susr1, nullptr);
  81. #endif
  82. }
  83. // -------------------------------------------------------------------------
  84. #ifdef HAVE_JUCE
  85. static CarlaBridge::CarlaBridgeClient* gBridgeClient = nullptr;
  86. class CarlaJuceApp : public JUCEApplication,
  87. Timer
  88. {
  89. public:
  90. CarlaJuceApp() {}
  91. ~CarlaJuceApp() {}
  92. void initialise(const String&) override
  93. {
  94. startTimer(30);
  95. }
  96. void shutdown() override
  97. {
  98. gCloseNow = true;
  99. stopTimer();
  100. }
  101. const String getApplicationName() override
  102. {
  103. return "CarlaPlugin";
  104. }
  105. const String getApplicationVersion() override
  106. {
  107. return CARLA_VERSION_STRING;
  108. }
  109. void timerCallback() override
  110. {
  111. carla_engine_idle();
  112. if (gBridgeClient != nullptr)
  113. gBridgeClient->oscIdle();
  114. if (gCloseNow)
  115. {
  116. quit();
  117. gCloseNow = false;
  118. }
  119. }
  120. };
  121. static JUCEApplicationBase* juce_CreateApplication() { return new CarlaJuceApp(); }
  122. #endif
  123. // -------------------------------------------------------------------------
  124. CARLA_BRIDGE_START_NAMESPACE
  125. #if 0
  126. } // Fix editor indentation
  127. #endif
  128. // -------------------------------------------------------------------------
  129. class CarlaPluginClient : public CarlaBridgeClient
  130. {
  131. public:
  132. CarlaPluginClient(const bool useBridge, const char* const clientName, const char* const audioBaseName, const char* const controlBaseName, const char* const timeBaseName)
  133. : CarlaBridgeClient(nullptr),
  134. fPlugin(nullptr),
  135. fEngine(nullptr)
  136. {
  137. CARLA_ASSERT(clientName != nullptr && clientName[0] != '\0');
  138. carla_debug("CarlaPluginClient::CarlaPluginClient(%s, \"%s\", %s, %s, %s)", bool2str(useBridge), clientName, audioBaseName, controlBaseName, timeBaseName);
  139. carla_set_engine_callback(callback, this);
  140. if (useBridge)
  141. carla_engine_init_bridge(audioBaseName, controlBaseName, timeBaseName, clientName);
  142. else
  143. carla_engine_init("JACK", clientName);
  144. fEngine = carla_get_engine();
  145. }
  146. ~CarlaPluginClient() override
  147. {
  148. carla_debug("CarlaPluginClient::~CarlaPluginClient()");
  149. #ifdef HAVE_JUCE
  150. gBridgeClient = nullptr;
  151. #endif
  152. carla_engine_close();
  153. }
  154. bool isOk() const noexcept
  155. {
  156. return (fEngine != nullptr);
  157. }
  158. void oscInit(const char* const url)
  159. {
  160. CarlaBridgeClient::oscInit(url);
  161. fEngine->setOscBridgeData(&fOscData);
  162. }
  163. void ready(const bool doSaveLoad)
  164. {
  165. fPlugin = fEngine->getPlugin(0);
  166. if (doSaveLoad)
  167. {
  168. fProjFileName = fPlugin->getName();
  169. fProjFileName += ".carxs";
  170. //if (! File::isAbsolutePath((const char*)fProjFileName))
  171. // fProjFileName = File::getCurrentWorkingDirectory().getChildFile((const char*)fProjFileName).getFullPathName().toRawUTF8();
  172. //if (! fPlugin->loadStateFromFile(fProjFileName))
  173. // carla_stderr("Plugin preset load failed, error was:\n%s", fEngine->getLastError());
  174. }
  175. }
  176. #ifndef HAVE_JUCE
  177. void idle()
  178. {
  179. CARLA_SAFE_ASSERT_RETURN(fEngine != nullptr,);
  180. CARLA_SAFE_ASSERT_RETURN(fPlugin != nullptr,);
  181. carla_engine_idle();
  182. CarlaBridgeClient::oscIdle();
  183. if (gSaveNow)
  184. {
  185. gSaveNow = false;
  186. if (fProjFileName.isNotEmpty())
  187. {
  188. if (! fPlugin->saveStateToFile(fProjFileName))
  189. carla_stderr("Plugin preset save failed, error was:\n%s", fEngine->getLastError());
  190. }
  191. }
  192. if (gCloseNow)
  193. {
  194. //gCloseNow = false;
  195. // close something?
  196. }
  197. }
  198. #endif
  199. void exec(int argc, char* argv[])
  200. {
  201. #ifdef HAVE_JUCE
  202. gBridgeClient = this;
  203. JUCEApplicationBase::createInstance = &juce_CreateApplication;
  204. JUCEApplicationBase::main(JUCE_MAIN_FUNCTION_ARGS);
  205. #else
  206. for (; ! gCloseNow;)
  207. {
  208. idle();
  209. carla_msleep(24);
  210. }
  211. #endif
  212. return; (void)argc; (void)argv;
  213. }
  214. // ---------------------------------------------------------------------
  215. // plugin management
  216. void saveNow()
  217. {
  218. CARLA_SAFE_ASSERT_RETURN(fEngine != nullptr,);
  219. CARLA_SAFE_ASSERT_RETURN(fPlugin != nullptr,);
  220. carla_debug("CarlaPluginClient::saveNow()");
  221. fPlugin->prepareForSave();
  222. for (uint32_t i=0; i < fPlugin->getCustomDataCount(); ++i)
  223. {
  224. const CarlaBackend::CustomData& cdata(fPlugin->getCustomData(i));
  225. fEngine->oscSend_bridge_set_custom_data(cdata.type, cdata.key, cdata.value);
  226. }
  227. if (fPlugin->getOptionsEnabled() & CarlaBackend::PLUGIN_OPTION_USE_CHUNKS)
  228. {
  229. void* data = nullptr;
  230. int32_t dataSize = fPlugin->getChunkData(&data);
  231. if (data && dataSize >= 4)
  232. {
  233. #if 0
  234. QString filePath;
  235. filePath = QDir::tempPath();
  236. #ifdef Q_OS_WIN
  237. filePath += "\\.CarlaChunk_";
  238. #else
  239. filePath += "/.CarlaChunk_";
  240. #endif
  241. filePath += fPlugin->getName();
  242. QFile file(filePath);
  243. if (file.open(QIODevice::WriteOnly))
  244. {
  245. QByteArray chunk((const char*)data, dataSize);
  246. file.write(chunk);
  247. file.close();
  248. fEngine->oscSend_bridge_set_chunk_data(filePath.toUtf8().constData());
  249. }
  250. #endif
  251. }
  252. }
  253. fEngine->oscSend_bridge_configure(CARLA_BRIDGE_MSG_SAVED, "");
  254. }
  255. void setParameterMidiChannel(const uint32_t index, const uint8_t channel)
  256. {
  257. CARLA_SAFE_ASSERT_RETURN(fPlugin != nullptr,);
  258. carla_debug("CarlaPluginClient::setParameterMidiChannel(%i, %i)", index, channel);
  259. fPlugin->setParameterMidiChannel(index, channel, false, false);
  260. }
  261. void setParameterMidiCC(const uint32_t index, const int16_t cc)
  262. {
  263. CARLA_SAFE_ASSERT_RETURN(fPlugin != nullptr,);
  264. carla_debug("CarlaPluginClient::setParameterMidiCC(%i, %i)", index, cc);
  265. fPlugin->setParameterMidiCC(index, cc, false, false);
  266. }
  267. void setCustomData(const char* const type, const char* const key, const char* const value)
  268. {
  269. CARLA_SAFE_ASSERT_RETURN(fPlugin != nullptr,);
  270. carla_debug("CarlaPluginClient::setCustomData(\"%s\", \"%s\", \"%s\")", type, key, value);
  271. fPlugin->setCustomData(type, key, value, true);
  272. }
  273. void setChunkData(const char* const filePath)
  274. {
  275. CARLA_SAFE_ASSERT_RETURN(filePath != nullptr && filePath[0] != '\0',);
  276. CARLA_SAFE_ASSERT_RETURN(fPlugin != nullptr,);
  277. carla_debug("CarlaPluginClient::setChunkData(\"%s\")", filePath);
  278. #if 0
  279. QString chunkFilePath(filePath);
  280. #ifdef CARLA_OS_WIN
  281. if (chunkFilePath.startsWith("/"))
  282. {
  283. // running under Wine, posix host
  284. chunkFilePath = chunkFilePath.replace(0, 1, "Z:/");
  285. chunkFilePath = QDir::toNativeSeparators(chunkFilePath);
  286. }
  287. #endif
  288. QFile chunkFile(chunkFilePath);
  289. if (fPlugin != nullptr && chunkFile.open(QIODevice::ReadOnly | QIODevice::Text))
  290. {
  291. QTextStream in(&chunkFile);
  292. QString stringData(in.readAll());
  293. chunkFile.close();
  294. chunkFile.remove();
  295. fPlugin->setChunkData(stringData.toUtf8().constData());
  296. }
  297. #endif
  298. }
  299. // ---------------------------------------------------------------------
  300. protected:
  301. void handleCallback(const CarlaBackend::EngineCallbackOpcode action, const int value1, const int value2, const float value3, const char* const valueStr)
  302. {
  303. CARLA_BACKEND_USE_NAMESPACE;
  304. // TODO
  305. switch (action)
  306. {
  307. case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  308. if (isOscControlRegistered())
  309. {
  310. CARLA_SAFE_ASSERT_RETURN(value1 >= 0,);
  311. fEngine->oscSend_bridge_parameter_value(static_cast<uint32_t>(value1), value3);
  312. }
  313. break;
  314. case ENGINE_CALLBACK_UI_STATE_CHANGED:
  315. if (! isOscControlRegistered())
  316. {
  317. if (value1 != 1 && gIsInitiated)
  318. gCloseNow = true;
  319. }
  320. else
  321. {
  322. // show-gui button
  323. fEngine->oscSend_bridge_configure(CARLA_BRIDGE_MSG_HIDE_GUI, "");
  324. }
  325. break;
  326. default:
  327. break;
  328. }
  329. return;
  330. (void)value2;
  331. (void)value3;
  332. (void)valueStr;
  333. }
  334. private:
  335. CarlaBackend::CarlaPlugin* fPlugin;
  336. const CarlaBackend::CarlaEngine* fEngine;
  337. CarlaString fProjFileName;
  338. static void callback(void* ptr, CarlaBackend::EngineCallbackOpcode action, unsigned int pluginId, int value1, int value2, float value3, const char* valueStr)
  339. {
  340. carla_debug("CarlaPluginClient::callback(%p, %i:%s, %i, %i, %i, %f, \"%s\")", ptr, action, CarlaBackend::EngineCallbackOpcode2Str(action), pluginId, value1, value2, value3, valueStr);
  341. CARLA_SAFE_ASSERT_RETURN(ptr != nullptr,);
  342. CARLA_SAFE_ASSERT_RETURN(pluginId == 0,);
  343. return ((CarlaPluginClient*)ptr)->handleCallback(action, value1, value2, value3, valueStr);
  344. }
  345. };
  346. // -------------------------------------------------------------------------
  347. int CarlaBridgeOsc::handleMsgShow()
  348. {
  349. carla_debug("CarlaBridgeOsc::handleMsgShow()");
  350. #ifdef HAVE_JUCE
  351. const juce::MessageManagerLock mmLock;
  352. #endif
  353. if (carla_get_plugin_info(0)->hints & CarlaBackend::PLUGIN_HAS_CUSTOM_UI)
  354. carla_show_custom_ui(0, true);
  355. return 0;
  356. }
  357. int CarlaBridgeOsc::handleMsgHide()
  358. {
  359. carla_debug("CarlaBridgeOsc::handleMsgHide()");
  360. #ifdef HAVE_JUCE
  361. const juce::MessageManagerLock mmLock;
  362. #endif
  363. if (carla_get_plugin_info(0)->hints & CarlaBackend::PLUGIN_HAS_CUSTOM_UI)
  364. carla_show_custom_ui(0, false);
  365. return 0;
  366. }
  367. int CarlaBridgeOsc::handleMsgQuit()
  368. {
  369. carla_debug("CarlaBridgeOsc::handleMsgQuit()");
  370. gCloseNow = true;
  371. return 0;
  372. }
  373. // -------------------------------------------------------------------------
  374. int CarlaBridgeOsc::handleMsgPluginSaveNow()
  375. {
  376. CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
  377. carla_debug("CarlaBridgeOsc::handleMsgPluginSaveNow()");
  378. CarlaPluginClient* const plugClient((CarlaPluginClient*)fClient);
  379. plugClient->saveNow();
  380. return 0;
  381. }
  382. int CarlaBridgeOsc::handleMsgPluginSetParameterMidiChannel(CARLA_BRIDGE_OSC_HANDLE_ARGS)
  383. {
  384. CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ii");
  385. CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
  386. carla_debug("CarlaBridgeOsc::handleMsgPluginSetParameterMidiChannel()");
  387. const int32_t index = argv[0]->i;
  388. const int32_t channel = argv[1]->i;
  389. CARLA_SAFE_ASSERT_RETURN(index >= 0, 0);
  390. CARLA_SAFE_ASSERT_RETURN(channel >= 0 && channel < MAX_MIDI_CHANNELS, 0);
  391. CarlaPluginClient* const plugClient((CarlaPluginClient*)fClient);
  392. plugClient->setParameterMidiChannel(static_cast<uint32_t>(index), static_cast<uint8_t>(channel));
  393. return 0;
  394. }
  395. int CarlaBridgeOsc::handleMsgPluginSetParameterMidiCC(CARLA_BRIDGE_OSC_HANDLE_ARGS)
  396. {
  397. CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ii");
  398. CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
  399. carla_debug("CarlaBridgeOsc::handleMsgPluginSetParameterMidiCC()");
  400. const int32_t index = argv[0]->i;
  401. const int32_t cc = argv[1]->i;
  402. CARLA_SAFE_ASSERT_RETURN(index >= 0, 0);
  403. CARLA_SAFE_ASSERT_RETURN(cc >= 1 && cc < 0x5F, 0);
  404. CarlaPluginClient* const plugClient((CarlaPluginClient*)fClient);
  405. plugClient->setParameterMidiCC(static_cast<uint32_t>(index), static_cast<int16_t>(cc));
  406. return 0;
  407. }
  408. int CarlaBridgeOsc::handleMsgPluginSetChunk(CARLA_BRIDGE_OSC_HANDLE_ARGS)
  409. {
  410. CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(1, "s");
  411. CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
  412. carla_debug("CarlaBridgeOsc::handleMsgPluginSetChunk()");
  413. const char* const chunkFile = (const char*)&argv[0]->s;
  414. CarlaPluginClient* const plugClient((CarlaPluginClient*)fClient);
  415. plugClient->setChunkData(chunkFile);
  416. return 0;
  417. }
  418. int CarlaBridgeOsc::handleMsgPluginSetCustomData(CARLA_BRIDGE_OSC_HANDLE_ARGS)
  419. {
  420. CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(3, "sss");
  421. CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
  422. carla_debug("CarlaBridgeOsc::handleMsgPluginSetCustomData()");
  423. const char* const type = (const char*)&argv[0]->s;
  424. const char* const key = (const char*)&argv[1]->s;
  425. const char* const value = (const char*)&argv[2]->s;
  426. CarlaPluginClient* const plugClient((CarlaPluginClient*)fClient);
  427. plugClient->setCustomData(type, key, value);
  428. return 0;
  429. }
  430. CARLA_BRIDGE_END_NAMESPACE
  431. // -------------------------------------------------------------------------
  432. CarlaPlugin* CarlaPlugin::newJACK(const CarlaPlugin::Initializer&)
  433. {
  434. return nullptr;
  435. }
  436. // -------------------------------------------------------------------------
  437. int main(int argc, char* argv[])
  438. {
  439. CARLA_BRIDGE_USE_NAMESPACE;
  440. // ---------------------------------------------------------------------
  441. // Check argument count
  442. if (argc != 7)
  443. {
  444. carla_stdout("usage: %s <osc-url|\"null\"> <type> <filename> <name|\"(none)\"> <label> <uniqueId>", argv[0]);
  445. return 1;
  446. }
  447. // ---------------------------------------------------------------------
  448. // Get args
  449. const char* const oscUrl = argv[1];
  450. const char* const stype = argv[2];
  451. const char* const filename = argv[3];
  452. const char* name = argv[4];
  453. const char* label = argv[5];
  454. const int64_t uniqueId = static_cast<int64_t>(std::atol(argv[6]));
  455. // ---------------------------------------------------------------------
  456. // Setup args
  457. const char* const shmIds(std::getenv("ENGINE_BRIDGE_SHM_IDS"));
  458. const bool useBridge = (shmIds != nullptr);
  459. const bool useOsc = (std::strcmp(oscUrl, "null") != 0 && std::strcmp(oscUrl, "(null)") != 0 && std::strcmp(oscUrl, "NULL") != 0);
  460. if (std::strcmp(name, "(none)") == 0)
  461. name = nullptr;
  462. //if (std::strlen(label) == 0)
  463. // label = nullptr;
  464. char bridgeBaseAudioName[6+1];
  465. char bridgeBaseControlName[6+1];
  466. char bridgeBaseTimeName[6+1];
  467. if (useBridge)
  468. {
  469. CARLA_SAFE_ASSERT_RETURN(std::strlen(shmIds) == 6*3, 1);
  470. std::strncpy(bridgeBaseAudioName, shmIds, 6);
  471. std::strncpy(bridgeBaseControlName, shmIds+6, 6);
  472. std::strncpy(bridgeBaseTimeName, shmIds+12, 6);
  473. bridgeBaseAudioName[6] = '\0';
  474. bridgeBaseControlName[6] = '\0';
  475. bridgeBaseTimeName[6] = '\0';
  476. }
  477. else
  478. {
  479. bridgeBaseAudioName[0] = '\0';
  480. bridgeBaseControlName[0] = '\0';
  481. bridgeBaseTimeName[0] = '\0';
  482. }
  483. // ---------------------------------------------------------------------
  484. // Check plugin type
  485. CarlaBackend::PluginType itype(CarlaBackend::getPluginTypeFromString(stype));
  486. if (itype == CarlaBackend::PLUGIN_NONE)
  487. {
  488. carla_stderr("Invalid plugin type '%s'", stype);
  489. return 1;
  490. }
  491. // ---------------------------------------------------------------------
  492. // Set client name
  493. CarlaString clientName((name != nullptr) ? name : label);
  494. //if (clientName.isEmpty())
  495. // clientName = File(filename).getFileNameWithoutExtension().toRawUTF8();
  496. // ---------------------------------------------------------------------
  497. // Set extraStuff
  498. const void* extraStuff = nullptr;
  499. if (itype == CarlaBackend::PLUGIN_FILE_GIG || itype == CarlaBackend::PLUGIN_FILE_SF2)
  500. {
  501. if (label == nullptr)
  502. label = clientName;
  503. if (std::strstr(label, " (16 outs)") == 0)
  504. extraStuff = "true";
  505. }
  506. // ---------------------------------------------------------------------
  507. // Init plugin client
  508. CarlaPluginClient client(useBridge, clientName, bridgeBaseAudioName, bridgeBaseControlName, bridgeBaseTimeName);
  509. if (! client.isOk())
  510. {
  511. carla_stderr("Failed to init engine, error was:\n%s", carla_get_last_error());
  512. return 1;
  513. }
  514. // ---------------------------------------------------------------------
  515. // Init OSC
  516. if (useOsc)
  517. client.oscInit(oscUrl);
  518. // ---------------------------------------------------------------------
  519. // Listen for ctrl+c or sigint/sigterm events
  520. initSignalHandler();
  521. // ---------------------------------------------------------------------
  522. // Init plugin
  523. int ret;
  524. if (carla_add_plugin(CarlaBackend::BINARY_NATIVE, itype, filename, name, label, uniqueId, extraStuff))
  525. {
  526. if (useOsc)
  527. {
  528. client.sendOscUpdate();
  529. client.sendOscBridgeUpdate();
  530. }
  531. else
  532. {
  533. carla_set_active(0, true);
  534. if (const CarlaPluginInfo* const pluginInfo = carla_get_plugin_info(0))
  535. {
  536. if (pluginInfo->hints & CarlaBackend::PLUGIN_HAS_CUSTOM_UI)
  537. carla_show_custom_ui(0, true);
  538. }
  539. }
  540. client.ready(!useOsc);
  541. gIsInitiated = true;
  542. client.exec(argc, argv);
  543. carla_set_engine_about_to_close();
  544. carla_remove_plugin(0);
  545. ret = 0;
  546. }
  547. else
  548. {
  549. const char* const lastError(carla_get_last_error());
  550. carla_stderr("Plugin failed to load, error was:\n%s", lastError);
  551. if (useOsc)
  552. client.sendOscBridgeError(lastError);
  553. ret = 1;
  554. }
  555. // ---------------------------------------------------------------------
  556. // Close OSC
  557. if (useOsc)
  558. client.oscClose();
  559. return ret;
  560. }