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.

CarlaStandaloneNSM.cpp 20KB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /*
  2. * Carla Standalone
  3. * Copyright (C) 2011-2015 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 "CarlaDefines.h"
  18. #ifdef HAVE_LIBLO
  19. #define NSM_API_VERSION_MAJOR 1
  20. #define NSM_API_VERSION_MINOR 2
  21. #define NSM_CLIENT_FEATURES ":switch:"
  22. //#define NSM_CLIENT_FEATURES ":switch:optional-gui:"
  23. #include "CarlaHost.h"
  24. #include "CarlaOscUtils.hpp"
  25. #include "CarlaString.hpp"
  26. #include "juce_core/juce_core.h"
  27. namespace CB = CarlaBackend;
  28. // -------------------------------------------------------------------------------------------------------------------
  29. struct CarlaBackendStandalone {
  30. CarlaEngine* engine;
  31. EngineCallbackFunc engineCallback;
  32. void* engineCallbackPtr;
  33. // ...
  34. };
  35. extern CarlaBackendStandalone gStandalone;
  36. // -------------------------------------------------------------------------------------------------------------------
  37. class CarlaNSM
  38. {
  39. public:
  40. CarlaNSM() noexcept
  41. : fReplyAddress(nullptr),
  42. fServer(nullptr),
  43. fServerThread(nullptr),
  44. fServerURL(nullptr),
  45. fClientNameId(),
  46. fProjectPath(),
  47. fHasBroadcast(false),
  48. fHasOptionalGui(false),
  49. fHasServerControl(false),
  50. fStarted(),
  51. fReadyActionOpen(true),
  52. fReadyActionSave(true) {}
  53. ~CarlaNSM()
  54. {
  55. CARLA_SAFE_ASSERT(fReadyActionOpen);
  56. CARLA_SAFE_ASSERT(fReadyActionSave);
  57. if (fServerThread != nullptr)
  58. {
  59. lo_server_thread_stop(fServerThread);
  60. lo_server_thread_free(fServerThread);
  61. fServerThread = nullptr;
  62. fServer = nullptr;
  63. }
  64. if (fServerURL != nullptr)
  65. {
  66. std::free(fServerURL);
  67. fServerURL = nullptr;
  68. }
  69. if (fReplyAddress != nullptr)
  70. {
  71. lo_address_free(fReplyAddress);
  72. fReplyAddress = nullptr;
  73. }
  74. }
  75. bool announce(const int pid, const char* const executableName)
  76. {
  77. CARLA_SAFE_ASSERT_RETURN(pid != 0, false);
  78. CARLA_SAFE_ASSERT_RETURN(executableName != nullptr && executableName[0] != '\0', false);
  79. const char* const NSM_URL(std::getenv("NSM_URL"));
  80. if (NSM_URL == nullptr)
  81. return false;
  82. const lo_address nsmAddress(lo_address_new_from_url(NSM_URL));
  83. CARLA_SAFE_ASSERT_RETURN(nsmAddress != nullptr, false);
  84. const int proto = lo_address_get_protocol(nsmAddress);
  85. if (fServerThread == nullptr)
  86. {
  87. // create new OSC server
  88. fServerThread = lo_server_thread_new_with_proto(nullptr, proto, _osc_error_handler);
  89. CARLA_SAFE_ASSERT_RETURN(fServerThread != nullptr, false);
  90. // register message handlers
  91. lo_server_thread_add_method(fServerThread, "/error", "sis", _error_handler, this);
  92. lo_server_thread_add_method(fServerThread, "/reply", "ssss", _reply_handler, this);
  93. lo_server_thread_add_method(fServerThread, "/nsm/client/open", "sss", _open_handler, this);
  94. lo_server_thread_add_method(fServerThread, "/nsm/client/save", "", _save_handler, this);
  95. lo_server_thread_add_method(fServerThread, "/nsm/client/session_is_loaded", "", _loaded_handler, this);
  96. lo_server_thread_add_method(fServerThread, "/nsm/client/show_optional_gui", "", _show_gui_handler, this);
  97. lo_server_thread_add_method(fServerThread, "/nsm/client/hide_optional_gui", "", _hide_gui_handler, this);
  98. lo_server_thread_add_method(fServerThread, nullptr, nullptr, _broadcast_handler, this);
  99. fServer = lo_server_thread_get_server(fServerThread);
  100. fServerURL = lo_server_thread_get_url(fServerThread);
  101. }
  102. lo_send_from(nsmAddress, fServer, LO_TT_IMMEDIATE, "/nsm/server/announce", "sssiii",
  103. "Carla", NSM_CLIENT_FEATURES, executableName, NSM_API_VERSION_MAJOR, NSM_API_VERSION_MINOR, pid);
  104. lo_address_free(nsmAddress);
  105. return true;
  106. }
  107. void ready(const int action)
  108. {
  109. CARLA_SAFE_ASSERT_RETURN(fServerThread != nullptr,);
  110. switch (action)
  111. {
  112. case -1: // init
  113. CARLA_SAFE_ASSERT_BREAK(! fStarted);
  114. fStarted = true;
  115. lo_server_thread_start(fServerThread);
  116. break;
  117. case 0: // error
  118. break;
  119. case 1: // reply
  120. break;
  121. case 2: // open
  122. fReadyActionOpen = true;
  123. break;
  124. case 3: // save
  125. fReadyActionSave = true;
  126. break;
  127. case 4: // session loaded
  128. break;
  129. case 5: // show gui
  130. CARLA_SAFE_ASSERT_BREAK(fReplyAddress != nullptr);
  131. CARLA_SAFE_ASSERT_BREAK(fServer != nullptr);
  132. lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/nsm/client/gui_is_shown", "");
  133. break;
  134. case 6: // hide gui
  135. CARLA_SAFE_ASSERT_BREAK(fReplyAddress != nullptr);
  136. CARLA_SAFE_ASSERT_BREAK(fServer != nullptr);
  137. lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/nsm/client/gui_is_hidden", "");
  138. break;
  139. }
  140. }
  141. static CarlaNSM& getInstance()
  142. {
  143. static CarlaNSM sInstance;
  144. return sInstance;
  145. }
  146. protected:
  147. int handleError(const char* const method, const int code, const char* const message)
  148. {
  149. carla_stdout("CarlaNSM::handleError(\"%s\", %i, \"%s\")", method, code, message);
  150. if (gStandalone.engineCallback != nullptr)
  151. gStandalone.engineCallback(gStandalone.engineCallbackPtr, CB::ENGINE_CALLBACK_NSM, 0, 0, code, 0.0f, message);
  152. return 1;
  153. // may be unused
  154. (void)method;
  155. }
  156. int handleReply(const char* const method, const char* const message, const char* const smName, const char* const features,
  157. const lo_message msg)
  158. {
  159. CARLA_SAFE_ASSERT_RETURN(fServerThread != nullptr, 1);
  160. carla_stdout("CarlaNSM::handleReply(\"%s\", \"%s\", \"%s\", \"%s\")", method, message, smName, features);
  161. if (std::strcmp(method, "/nsm/server/announce") == 0)
  162. {
  163. const lo_address msgAddress(lo_message_get_source(msg));
  164. CARLA_SAFE_ASSERT_RETURN(msgAddress != nullptr, 0);
  165. char* const msgURL(lo_address_get_url(msgAddress));
  166. CARLA_SAFE_ASSERT_RETURN(msgURL != nullptr, 0);
  167. if (fReplyAddress != nullptr)
  168. lo_address_free(fReplyAddress);
  169. fReplyAddress = lo_address_new_from_url(msgURL);
  170. CARLA_SAFE_ASSERT_RETURN(fReplyAddress != nullptr, 0);
  171. fHasBroadcast = std::strstr(features, ":broadcast:") != nullptr;
  172. fHasOptionalGui = std::strstr(features, ":optional-gui:") != nullptr;
  173. fHasServerControl = std::strstr(features, ":server_control:") != nullptr;
  174. #if 0
  175. // UI starts visible
  176. if (fHasOptionalGui)
  177. lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/nsm/client/gui_is_shown", "");
  178. #endif
  179. carla_stdout("Carla started via '%s', message: %s", smName, message);
  180. if (gStandalone.engineCallback != nullptr)
  181. {
  182. int flags = 0;
  183. if (fHasBroadcast)
  184. flags |= 1 << 0;
  185. if (fHasOptionalGui)
  186. flags |= 1 << 1;
  187. if (fHasServerControl)
  188. flags |= 1 << 2;
  189. gStandalone.engineCallback(gStandalone.engineCallbackPtr, CB::ENGINE_CALLBACK_NSM, 0, 1, flags, 0.0f, smName);
  190. }
  191. std::free(msgURL);
  192. }
  193. else
  194. {
  195. carla_stdout("Got unknown NSM reply method '%s'", method);
  196. }
  197. return 0;
  198. }
  199. int handleOpen(const char* const projectPath, const char* const displayName, const char* const clientNameId)
  200. {
  201. CARLA_SAFE_ASSERT_RETURN(fReplyAddress != nullptr, 1);
  202. CARLA_SAFE_ASSERT_RETURN(fServer != nullptr, 1);
  203. carla_stdout("CarlaNSM::handleOpen(\"%s\", \"%s\", \"%s\")", projectPath, displayName, clientNameId);
  204. if (gStandalone.engineCallback != nullptr)
  205. {
  206. fReadyActionOpen = false;
  207. gStandalone.engineCallback(gStandalone.engineCallbackPtr, CB::ENGINE_CALLBACK_NSM, 0, 2, 0, 0.0f, projectPath);
  208. for (; ! fReadyActionOpen;)
  209. carla_msleep(10);
  210. }
  211. else
  212. {
  213. using namespace juce;
  214. if (carla_is_engine_running())
  215. carla_engine_close();
  216. carla_engine_init("JACK", clientNameId);
  217. fProjectPath = projectPath;
  218. fProjectPath += ".carxp";
  219. const String jfilename = String(CharPointer_UTF8(fProjectPath));
  220. if (File(jfilename).existsAsFile())
  221. carla_load_project(fProjectPath);
  222. }
  223. fClientNameId = clientNameId;
  224. lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/open", "OK");
  225. // Broadcast ourselves
  226. if (fHasBroadcast)
  227. {
  228. lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/nsm/server/broadcast", "sssss",
  229. "/non/hello", fServerURL, "Carla", CARLA_VERSION_STRING, fClientNameId.buffer());
  230. }
  231. return 0;
  232. }
  233. int handleSave()
  234. {
  235. CARLA_SAFE_ASSERT_RETURN(fReplyAddress != nullptr, 1);
  236. CARLA_SAFE_ASSERT_RETURN(fServer != nullptr, 1);
  237. carla_stdout("CarlaNSM::handleSave()");
  238. if (gStandalone.engineCallback != nullptr)
  239. {
  240. fReadyActionSave = false;
  241. gStandalone.engineCallback(gStandalone.engineCallbackPtr, CB::ENGINE_CALLBACK_NSM, 0, 3, 0, 0.0f, nullptr);
  242. for (; ! fReadyActionSave;)
  243. carla_msleep(10);
  244. }
  245. else
  246. {
  247. CARLA_SAFE_ASSERT_RETURN(fProjectPath.isNotEmpty(), 0);
  248. carla_save_project(fProjectPath);
  249. }
  250. lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/save", "OK");
  251. return 0;
  252. }
  253. int handleSessionIsLoaded()
  254. {
  255. CARLA_SAFE_ASSERT_RETURN(fReplyAddress != nullptr, 1);
  256. CARLA_SAFE_ASSERT_RETURN(fServer != nullptr, 1);
  257. carla_stdout("CarlaNSM::handleSessionIsLoaded()");
  258. if (gStandalone.engineCallback != nullptr)
  259. gStandalone.engineCallback(gStandalone.engineCallbackPtr, CB::ENGINE_CALLBACK_NSM, 0, 4, 0, 0.0f, nullptr);
  260. return 0;
  261. }
  262. int handleShowOptionalGui()
  263. {
  264. CARLA_SAFE_ASSERT_RETURN(fReplyAddress != nullptr, 1);
  265. CARLA_SAFE_ASSERT_RETURN(fServer != nullptr, 1);
  266. carla_stdout("CarlaNSM::handleShowOptionalGui()");
  267. if (gStandalone.engineCallback != nullptr)
  268. gStandalone.engineCallback(gStandalone.engineCallbackPtr, CB::ENGINE_CALLBACK_NSM, 0, 5, 0, 0.0f, nullptr);
  269. return 0;
  270. }
  271. int handleHideOptionalGui()
  272. {
  273. CARLA_SAFE_ASSERT_RETURN(fReplyAddress != nullptr, 1);
  274. CARLA_SAFE_ASSERT_RETURN(fServer != nullptr, 1);
  275. carla_stdout("CarlaNSM::handleHideOptionalGui()");
  276. if (gStandalone.engineCallback != nullptr)
  277. gStandalone.engineCallback(gStandalone.engineCallbackPtr, CB::ENGINE_CALLBACK_NSM, 0, 6, 0, 0.0f, nullptr);
  278. return 0;
  279. }
  280. int handleBroadcast(const char* const path, const char* const types, lo_arg** const argv, const int argc,
  281. const lo_message msg)
  282. {
  283. CARLA_SAFE_ASSERT_RETURN(fReplyAddress != nullptr, 1);
  284. CARLA_SAFE_ASSERT_RETURN(fServer != nullptr, 1);
  285. CARLA_SAFE_ASSERT_RETURN(argc >= 0, 0);
  286. carla_stdout("CarlaNSM::handleBroadcast(%s, %s, %p, %i)", path, types, argv, argc);
  287. #if 0
  288. if (std::strcmp(path, "/non/hello") == 0)
  289. {
  290. CARLA_SAFE_ASSERT_RETURN(argc == 4, 0);
  291. CARLA_SAFE_ASSERT_RETURN(std::strcmp(types, "ssss") == 0, 0);
  292. const char* const url = &argv[0]->s;
  293. //const char* const name = &argv[1]->s;
  294. //const char* const version = &argv[2]->s;
  295. //const char* const clientId = &argv[3]->s;
  296. const lo_address targetAddress(lo_address_new_from_url(url));
  297. CARLA_SAFE_ASSERT_RETURN(targetAddress != nullptr, 0);
  298. lo_send_from(targetAddress, fServer, LO_TT_IMMEDIATE, "/signal/hello", "ss",
  299. fClientNameId.buffer(), fServerURL);
  300. lo_address_free(targetAddress);
  301. return 0;
  302. }
  303. if (std::strcmp(path, "/signal/hello") == 0)
  304. {
  305. //const char* const name = &argv[0]->s;
  306. const char* const url = &argv[1]->s;
  307. const lo_address targetAddress(lo_address_new_from_url(url));
  308. CARLA_SAFE_ASSERT_RETURN(targetAddress != nullptr, 0);
  309. lo_send_from(targetAddress, fServer, LO_TT_IMMEDIATE, "/signal/hello", "ss",
  310. fClientNameId.buffer(), fServerURL);
  311. lo_address_free(targetAddress);
  312. return 0;
  313. }
  314. if (std::strcmp(path, "/signal/list") == 0)
  315. {
  316. carla_stdout("CarlaNSM::handleBroadcast - got list");
  317. CARLA_SAFE_ASSERT_RETURN(carla_is_engine_running(), 0);
  318. const char* prefix = nullptr;
  319. if (argc > 0)
  320. prefix = &argv[0]->s;
  321. const lo_address msgAddress(lo_message_get_source(msg));
  322. CARLA_SAFE_ASSERT_RETURN(msgAddress != nullptr, 0);
  323. for (uint32_t i = 0, pluginCount = carla_get_current_plugin_count(); i < pluginCount; ++i)
  324. {
  325. const CarlaPluginInfo* const pluginInfo(carla_get_plugin_info(i));
  326. CARLA_SAFE_ASSERT_CONTINUE(pluginInfo != nullptr);
  327. /*const*/ CarlaString pluginNameId(fClientNameId + "/" + CarlaString(pluginInfo->name).replace('/','_') + "/");
  328. for (uint32_t j=0, paramCount = carla_get_parameter_count(i); j < paramCount; ++j)
  329. {
  330. const CarlaParameterInfo* const paramInfo(carla_get_parameter_info(i, j));
  331. CARLA_SAFE_ASSERT_CONTINUE(paramInfo != nullptr);
  332. const ParameterData* const paramData(carla_get_parameter_data(i, j));
  333. CARLA_SAFE_ASSERT_CONTINUE(paramData != nullptr);
  334. const ParameterRanges* const paramRanges(carla_get_parameter_ranges(i, j));
  335. CARLA_SAFE_ASSERT_CONTINUE(paramRanges != nullptr);
  336. if (paramData->type != CB::PARAMETER_INPUT /*&& paramData->type != CB::PARAMETER_OUTPUT*/)
  337. continue;
  338. if ((paramData->hints & CB::PARAMETER_IS_ENABLED) == 0)
  339. continue;
  340. if ((paramData->hints & CB::PARAMETER_IS_AUTOMABLE) == 0)
  341. continue;
  342. if (paramData->hints & CB::PARAMETER_IS_READ_ONLY)
  343. continue;
  344. const char* const dir = paramData->type == CB::PARAMETER_INPUT ? "in" : "out";
  345. const CarlaString paramNameId = pluginNameId + CarlaString(paramInfo->name).replace('/','_');
  346. const float defNorm = paramRanges->getNormalizedValue(paramRanges->def);
  347. if (prefix == nullptr || std::strncmp(paramNameId, prefix, std::strlen(prefix)) == 0)
  348. {
  349. lo_send_from(msgAddress, fServer, LO_TT_IMMEDIATE, "/reply", "sssfff",
  350. path, paramNameId.buffer(), dir, 0.0f, 1.0f, defNorm);
  351. }
  352. }
  353. }
  354. lo_send_from(msgAddress, fServer, LO_TT_IMMEDIATE, "/reply", "s", path);
  355. //return 0;
  356. }
  357. for (int i=0; i<argc; ++i)
  358. if (types[i] == 's')
  359. carla_stdout("%i: %s", i+1, &argv[i]->s);
  360. #endif
  361. return 0;
  362. // unused
  363. (void)msg;
  364. }
  365. private:
  366. lo_address fReplyAddress;
  367. lo_server fServer;
  368. lo_server_thread fServerThread;
  369. char* fServerURL;
  370. CarlaString fClientNameId;
  371. CarlaString fProjectPath;
  372. bool fHasBroadcast;
  373. bool fHasOptionalGui;
  374. bool fHasServerControl;
  375. bool fStarted;
  376. volatile bool fReadyActionOpen;
  377. volatile bool fReadyActionSave;
  378. #define handlePtr ((CarlaNSM*)data)
  379. static void _osc_error_handler(int num, const char* msg, const char* path)
  380. {
  381. carla_stderr2("CarlaNSM::_osc_error_handler(%i, \"%s\", \"%s\")", num, msg, path);
  382. }
  383. static int _error_handler(const char*, const char* types, lo_arg** argv, int argc, lo_message, void* data)
  384. {
  385. CARLA_SAFE_ASSERT_RETURN(argc == 3, 1);
  386. CARLA_SAFE_ASSERT_RETURN(std::strcmp(types, "sis") == 0, 1);
  387. const char* const method = &argv[0]->s;
  388. const int code = argv[1]->i;
  389. const char* const message = &argv[2]->s;
  390. return handlePtr->handleError(method, code, message);
  391. }
  392. static int _reply_handler(const char*, const char* types, lo_arg** argv, int argc, lo_message msg, void* data)
  393. {
  394. CARLA_SAFE_ASSERT_RETURN(argc == 4, 1);
  395. CARLA_SAFE_ASSERT_RETURN(std::strcmp(types, "ssss") == 0, 1);
  396. const char* const method = &argv[0]->s;
  397. const char* const message = &argv[1]->s;
  398. const char* const smName = &argv[2]->s;
  399. const char* const features = &argv[3]->s;
  400. return handlePtr->handleReply(method, message, smName, features, msg);
  401. }
  402. static int _open_handler(const char*, const char* types, lo_arg** argv, int argc, lo_message, void* data)
  403. {
  404. CARLA_SAFE_ASSERT_RETURN(argc == 3, 1);
  405. CARLA_SAFE_ASSERT_RETURN(std::strcmp(types, "sss") == 0, 1);
  406. const char* const projectPath = &argv[0]->s;
  407. const char* const displayName = &argv[1]->s;
  408. const char* const clientNameId = &argv[2]->s;
  409. return handlePtr->handleOpen(projectPath, displayName, clientNameId);
  410. }
  411. static int _save_handler(const char*, const char*, lo_arg**, int argc, lo_message, void* data)
  412. {
  413. CARLA_SAFE_ASSERT_RETURN(argc == 0, 1);
  414. return handlePtr->handleSave();
  415. }
  416. static int _loaded_handler(const char*, const char*, lo_arg**, int argc, lo_message, void* data)
  417. {
  418. CARLA_SAFE_ASSERT_RETURN(argc == 0, 1);
  419. return handlePtr->handleSessionIsLoaded();
  420. }
  421. static int _show_gui_handler(const char*, const char*, lo_arg**, int argc, lo_message, void* data)
  422. {
  423. CARLA_SAFE_ASSERT_RETURN(argc == 0, 1);
  424. return handlePtr->handleShowOptionalGui();
  425. }
  426. static int _hide_gui_handler(const char*, const char*, lo_arg**, int argc, lo_message, void* data)
  427. {
  428. CARLA_SAFE_ASSERT_RETURN(argc == 0, 1);
  429. return handlePtr->handleHideOptionalGui();
  430. }
  431. static int _broadcast_handler(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* data)
  432. {
  433. return handlePtr->handleBroadcast(path, types, argv, argc, msg);
  434. }
  435. #undef handlePtr
  436. CARLA_PREVENT_HEAP_ALLOCATION
  437. CARLA_DECLARE_NON_COPY_CLASS(CarlaNSM)
  438. };
  439. #endif // HAVE_LIBLO
  440. // -------------------------------------------------------------------------------------------------------------------
  441. CARLA_EXPORT
  442. bool carla_nsm_init(int pid, const char* executableName);
  443. bool carla_nsm_init(int pid, const char* executableName)
  444. {
  445. #ifdef HAVE_LIBLO
  446. return CarlaNSM::getInstance().announce(pid, executableName);
  447. #else
  448. return false;
  449. // unused
  450. (void)pid; (void)executableName;
  451. #endif
  452. }
  453. CARLA_EXPORT
  454. void carla_nsm_ready(int action);
  455. void carla_nsm_ready(int action)
  456. {
  457. #ifdef HAVE_LIBLO
  458. CarlaNSM::getInstance().ready(action);
  459. #endif
  460. }
  461. // -------------------------------------------------------------------------------------------------------------------