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.

712 lines
22KB

  1. /*
  2. * Carla LV2 Single Plugin
  3. * Copyright (C) 2017-2018 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. #ifndef BUILD_BRIDGE
  18. # error This file should not be compiled if not building bridge
  19. #endif
  20. #include "engine/CarlaEngineInternal.hpp"
  21. #include "CarlaPlugin.hpp"
  22. #include "CarlaBackendUtils.hpp"
  23. #include "CarlaEngineUtils.hpp"
  24. #include "CarlaLv2Utils.hpp"
  25. #include "CarlaUtils.h"
  26. #include "water/files/File.h"
  27. // --------------------------------------------------------------------------------------------------------------------
  28. CARLA_BACKEND_START_NAMESPACE
  29. class CarlaEngineSingleLV2 : public CarlaEngine,
  30. public Lv2PluginBaseClass<EngineTimeInfo>
  31. {
  32. public:
  33. CarlaEngineSingleLV2(const double sampleRate,
  34. const char* const bundlePath,
  35. const LV2_Feature* const* const features)
  36. : Lv2PluginBaseClass(sampleRate, features),
  37. fPlugin(nullptr),
  38. fUiName()
  39. {
  40. CARLA_SAFE_ASSERT_RETURN(pData->curPluginCount == 0,)
  41. CARLA_SAFE_ASSERT_RETURN(pData->plugins[0].plugin == nullptr,);
  42. if (! loadedInProperHost())
  43. return;
  44. // xxxxx
  45. CarlaString binaryDir(bundlePath);
  46. binaryDir += CARLA_OS_SEP_STR "bin" CARLA_OS_SEP_STR;
  47. CarlaString resourceDir(bundlePath);
  48. resourceDir += CARLA_OS_SEP_STR "res" CARLA_OS_SEP_STR;
  49. pData->bufferSize = fBufferSize;
  50. pData->sampleRate = sampleRate;
  51. pData->initTime(nullptr);
  52. pData->options.processMode = ENGINE_PROCESS_MODE_BRIDGE;
  53. pData->options.transportMode = ENGINE_TRANSPORT_MODE_PLUGIN;
  54. pData->options.forceStereo = false;
  55. pData->options.preferPluginBridges = false;
  56. pData->options.preferUiBridges = false;
  57. init("LV2-Export");
  58. if (pData->options.resourceDir != nullptr)
  59. delete[] pData->options.resourceDir;
  60. if (pData->options.binaryDir != nullptr)
  61. delete[] pData->options.binaryDir;
  62. pData->options.binaryDir = binaryDir.dup();
  63. pData->options.resourceDir = resourceDir.dup();
  64. setCallback(_engine_callback, this);
  65. using water::File;
  66. const File pluginFile(File::getSpecialLocation(File::currentExecutableFile).withFileExtension("xml"));
  67. if (! loadProject(pluginFile.getFullPathName().toRawUTF8()))
  68. {
  69. carla_stderr2("Failed to init plugin, possible reasons: %s", getLastError());
  70. return;
  71. }
  72. CARLA_SAFE_ASSERT_RETURN(pData->curPluginCount == 1,)
  73. fPlugin = pData->plugins[0].plugin;
  74. CARLA_SAFE_ASSERT_RETURN(fPlugin != nullptr,);
  75. CARLA_SAFE_ASSERT_RETURN(fPlugin->isEnabled(),);
  76. fPorts.usesTime = true;
  77. fPorts.numAudioIns = fPlugin->getAudioInCount();
  78. fPorts.numAudioOuts = fPlugin->getAudioOutCount();
  79. fPorts.numMidiIns = fPlugin->getMidiInCount();
  80. fPorts.numMidiOuts = fPlugin->getMidiOutCount();
  81. fPorts.numParams = fPlugin->getParameterCount();
  82. fPorts.init();
  83. for (uint32_t i=0; i < fPorts.numParams; ++i)
  84. {
  85. fPorts.paramsLast[i] = fPlugin->getParameterValue(i);
  86. fPorts.paramsOut [i] = fPlugin->isParameterOutput(i);
  87. }
  88. }
  89. ~CarlaEngineSingleLV2()
  90. {
  91. if (fPlugin != nullptr && fIsActive)
  92. fPlugin->setActive(false, false, false);
  93. close();
  94. }
  95. bool hasPlugin() noexcept
  96. {
  97. return fPlugin != nullptr;
  98. }
  99. // ----------------------------------------------------------------------------------------------------------------
  100. // LV2 functions
  101. void lv2_activate() noexcept
  102. {
  103. CARLA_SAFE_ASSERT_RETURN(! fIsActive,);
  104. resetTimeInfo();
  105. fPlugin->setActive(true, false, false);
  106. fIsActive = true;
  107. }
  108. void lv2_deactivate() noexcept
  109. {
  110. CARLA_SAFE_ASSERT_RETURN(fIsActive,);
  111. fIsActive = false;
  112. fPlugin->setActive(false, false, false);
  113. }
  114. void lv2_run(const uint32_t frames)
  115. {
  116. //const PendingRtEventsRunner prt(this, frames);
  117. if (! lv2_pre_run(frames))
  118. {
  119. updateParameterOutputs();
  120. return;
  121. }
  122. if (fPorts.numMidiIns > 0)
  123. {
  124. uint32_t engineEventIndex = 0;
  125. carla_zeroStructs(pData->events.in, kMaxEngineEventInternalCount);
  126. for (uint32_t i=0; i < fPorts.numMidiIns; ++i)
  127. {
  128. LV2_ATOM_SEQUENCE_FOREACH(fPorts.eventsIn[i], event)
  129. {
  130. if (event == nullptr)
  131. continue;
  132. if (event->body.type != fURIs.midiEvent)
  133. continue;
  134. if (event->body.size > 4)
  135. continue;
  136. if (event->time.frames >= frames)
  137. break;
  138. const uint8_t* const data((const uint8_t*)(event + 1));
  139. EngineEvent& engineEvent(pData->events.in[engineEventIndex++]);
  140. engineEvent.time = (uint32_t)event->time.frames;
  141. engineEvent.fillFromMidiData((uint8_t)event->body.size, data, (uint8_t)i);
  142. if (engineEventIndex >= kMaxEngineEventInternalCount)
  143. break;
  144. }
  145. }
  146. }
  147. if (fPorts.numMidiOuts > 0)
  148. {
  149. carla_zeroStructs(pData->events.out, kMaxEngineEventInternalCount);
  150. }
  151. if (fPlugin->tryLock(fIsOffline))
  152. {
  153. fPlugin->initBuffers();
  154. fPlugin->process(fPorts.audioIns, fPorts.audioOuts, nullptr, nullptr, frames);
  155. fPlugin->unlock();
  156. if (fPorts.numMidiOuts > 0)
  157. {
  158. uint8_t port = 0;
  159. uint8_t size = 0;
  160. uint8_t mdata[3] = { 0, 0, 0 };
  161. const uint8_t* mdataPtr = mdata;
  162. uint8_t mdataTmp[EngineMidiEvent::kDataSize];
  163. for (ushort i=0; i < kMaxEngineEventInternalCount; ++i)
  164. {
  165. const EngineEvent& engineEvent(pData->events.out[i]);
  166. /**/ if (engineEvent.type == kEngineEventTypeNull)
  167. {
  168. break;
  169. }
  170. else if (engineEvent.type == kEngineEventTypeControl)
  171. {
  172. const EngineControlEvent& ctrlEvent(engineEvent.ctrl);
  173. size = ctrlEvent.convertToMidiData(engineEvent.channel, mdata);
  174. mdataPtr = mdata;
  175. }
  176. else if (engineEvent.type == kEngineEventTypeMidi)
  177. {
  178. const EngineMidiEvent& midiEvent(engineEvent.midi);
  179. port = midiEvent.port;
  180. size = midiEvent.size;
  181. if (size > EngineMidiEvent::kDataSize)
  182. {
  183. CARLA_SAFE_ASSERT_CONTINUE(midiEvent.dataExt != nullptr);
  184. mdataPtr = midiEvent.dataExt;
  185. }
  186. else
  187. {
  188. // copy
  189. carla_copy<uint8_t>(mdataTmp, midiEvent.data, size);
  190. // add channel
  191. mdataTmp[0] = static_cast<uint8_t>(mdataTmp[0] | (engineEvent.channel & MIDI_CHANNEL_BIT));
  192. // done
  193. mdataPtr = mdataTmp;
  194. }
  195. }
  196. if (size > 0 && ! writeMidiEvent(port, engineEvent.time, size, mdataPtr))
  197. break;
  198. }
  199. }
  200. }
  201. else
  202. {
  203. for (uint32_t i=0; i<fPorts.numAudioOuts; ++i)
  204. carla_zeroFloats(fPorts.audioOuts[i], frames);
  205. }
  206. lv2_post_run(frames);
  207. updateParameterOutputs();
  208. }
  209. // ----------------------------------------------------------------------------------------------------------------
  210. bool lv2ui_instantiate(LV2UI_Write_Function writeFunction, LV2UI_Controller controller,
  211. LV2UI_Widget* widget, const LV2_Feature* const* features)
  212. {
  213. fUI.writeFunction = writeFunction;
  214. fUI.controller = controller;
  215. fUI.host = nullptr;
  216. fUiName.clear();
  217. const LV2_URID_Map* uridMap = nullptr;
  218. // ------------------------------------------------------------------------------------------------------------
  219. // see if the host supports external-ui, get uridMap
  220. for (int i=0; features[i] != nullptr; ++i)
  221. {
  222. if (std::strcmp(features[i]->URI, LV2_EXTERNAL_UI__Host) == 0 ||
  223. std::strcmp(features[i]->URI, LV2_EXTERNAL_UI_DEPRECATED_URI) == 0)
  224. {
  225. fUI.host = (const LV2_External_UI_Host*)features[i]->data;
  226. }
  227. else if (std::strcmp(features[i]->URI, LV2_URID__map) == 0)
  228. {
  229. uridMap = (const LV2_URID_Map*)features[i]->data;
  230. }
  231. }
  232. if (fUI.host != nullptr)
  233. {
  234. fUiName = fUI.host->plugin_human_id;
  235. *widget = (LV2_External_UI_Widget_Compat*)this;
  236. return true;
  237. }
  238. // ------------------------------------------------------------------------------------------------------------
  239. // no external-ui support, use showInterface
  240. for (int i=0; features[i] != nullptr; ++i)
  241. {
  242. if (std::strcmp(features[i]->URI, LV2_OPTIONS__options) == 0)
  243. {
  244. const LV2_Options_Option* const options((const LV2_Options_Option*)features[i]->data);
  245. for (int j=0; options[j].key != 0; ++j)
  246. {
  247. if (options[j].key == uridMap->map(uridMap->handle, LV2_UI__windowTitle))
  248. {
  249. fUiName = (const char*)options[j].value;
  250. break;
  251. }
  252. }
  253. break;
  254. }
  255. }
  256. if (fUiName.isEmpty())
  257. fUiName = fPlugin->getName();
  258. *widget = nullptr;
  259. return true;
  260. }
  261. void lv2ui_port_event(uint32_t portIndex, uint32_t bufferSize, uint32_t format, const void* buffer) const
  262. {
  263. if (format != 0 || bufferSize != sizeof(float) || buffer == nullptr)
  264. return;
  265. if (portIndex >= fPorts.indexOffset || ! fUI.isVisible)
  266. return;
  267. const float value(*(const float*)buffer);
  268. fPlugin->uiParameterChange(portIndex-fPorts.indexOffset, value);
  269. }
  270. protected:
  271. // ----------------------------------------------------------------------------------------------------------------
  272. // CarlaEngine virtual calls
  273. bool init(const char* const clientName) override
  274. {
  275. carla_stdout("CarlaEngineNative::init(\"%s\")", clientName);
  276. if (! pData->init(clientName))
  277. {
  278. close();
  279. setLastError("Failed to init internal data");
  280. return false;
  281. }
  282. return true;
  283. }
  284. bool isRunning() const noexcept override
  285. {
  286. return fIsActive;
  287. }
  288. bool isOffline() const noexcept override
  289. {
  290. return fIsOffline;
  291. }
  292. bool usesConstantBufferSize() const noexcept override
  293. {
  294. return false;
  295. }
  296. EngineType getType() const noexcept override
  297. {
  298. return kEngineTypePlugin;
  299. }
  300. const char* getCurrentDriverName() const noexcept override
  301. {
  302. return "LV2 Plugin";
  303. }
  304. void engineCallback(const EngineCallbackOpcode action, const uint pluginId, const int value1, const int value2, const float value3, const char* const valueStr)
  305. {
  306. switch (action)
  307. {
  308. case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  309. CARLA_SAFE_ASSERT_RETURN(value1 >= 0,);
  310. if (fUI.writeFunction != nullptr && fUI.controller != nullptr && fUI.isVisible)
  311. {
  312. fUI.writeFunction(fUI.controller,
  313. static_cast<uint32_t>(value1)+fPorts.indexOffset,
  314. sizeof(float), 0, &value3);
  315. }
  316. break;
  317. case ENGINE_CALLBACK_UI_STATE_CHANGED:
  318. fUI.isVisible = (value1 == 1);
  319. if (fUI.host != nullptr)
  320. fUI.host->ui_closed(fUI.controller);
  321. break;
  322. case ENGINE_CALLBACK_IDLE:
  323. break;
  324. default:
  325. carla_stdout("engineCallback(%i:%s, %u, %i, %i, %f, %s)",
  326. action, EngineCallbackOpcode2Str(action), pluginId, value1, value2, value3, valueStr);
  327. break;
  328. }
  329. }
  330. // ----------------------------------------------------------------------------------------------------------------
  331. void handleUiRun() const override
  332. {
  333. try {
  334. fPlugin->uiIdle();
  335. } CARLA_SAFE_EXCEPTION("fPlugin->uiIdle()")
  336. }
  337. void handleUiShow() override
  338. {
  339. fPlugin->showCustomUI(true);
  340. fUI.isVisible = true;
  341. }
  342. void handleUiHide() override
  343. {
  344. fUI.isVisible = false;
  345. fPlugin->showCustomUI(false);
  346. }
  347. // ----------------------------------------------------------------------------------------------------------------
  348. void handleParameterValueChanged(const uint32_t index, const float value) override
  349. {
  350. fPlugin->setParameterValue(index, value, false, false, false);
  351. }
  352. void handleBufferSizeChanged(const uint32_t bufferSize) override
  353. {
  354. CarlaEngine::bufferSizeChanged(bufferSize);
  355. }
  356. void handleSampleRateChanged(const double sampleRate) override
  357. {
  358. CarlaEngine::sampleRateChanged(sampleRate);
  359. }
  360. // ----------------------------------------------------------------------------------------------------------------
  361. private:
  362. CarlaPlugin* fPlugin;
  363. CarlaString fUiName;
  364. void updateParameterOutputs() noexcept
  365. {
  366. float value;
  367. for (uint32_t i=0; i < fPorts.numParams; ++i)
  368. {
  369. if (! fPorts.paramsOut[i])
  370. continue;
  371. fPorts.paramsLast[i] = value = fPlugin->getParameterValue(i);
  372. if (fPorts.paramsPtr[i] != nullptr)
  373. *fPorts.paramsPtr[i] = value;
  374. }
  375. }
  376. bool writeMidiEvent(const uint8_t port, const uint32_t time, const uint8_t midiSize, const uint8_t* midiData)
  377. {
  378. CARLA_SAFE_ASSERT_RETURN(fPorts.numMidiOuts > 0, false);
  379. CARLA_SAFE_ASSERT_RETURN(port < fPorts.numMidiOuts, false);
  380. CARLA_SAFE_ASSERT_RETURN(midiData != nullptr, false);
  381. CARLA_SAFE_ASSERT_RETURN(midiSize > 0, false);
  382. LV2_Atom_Sequence* const seq(fPorts.midiOuts[port]);
  383. CARLA_SAFE_ASSERT_RETURN(seq != nullptr, false);
  384. Ports::MidiOutData& mData(fPorts.midiOutData[port]);
  385. if (sizeof(LV2_Atom_Event) + midiSize > mData.capacity - mData.offset)
  386. return false;
  387. LV2_Atom_Event* const aev = (LV2_Atom_Event*)(LV2_ATOM_CONTENTS(LV2_Atom_Sequence, seq) + mData.offset);
  388. aev->time.frames = time;
  389. aev->body.size = midiSize;
  390. aev->body.type = fURIs.midiEvent;
  391. std::memcpy(LV2_ATOM_BODY(&aev->body), midiData, midiSize);
  392. const uint32_t size = lv2_atom_pad_size(static_cast<uint32_t>(sizeof(LV2_Atom_Event) + midiSize));
  393. mData.offset += size;
  394. seq->atom.size += size;
  395. return true;
  396. }
  397. // -------------------------------------------------------------------
  398. #define handlePtr ((CarlaEngineSingleLV2*)handle)
  399. static void _engine_callback(void* handle, EngineCallbackOpcode action, uint pluginId, int value1, int value2, float value3, const char* valueStr)
  400. {
  401. handlePtr->engineCallback(action, pluginId, value1, value2, value3, valueStr);
  402. }
  403. #undef handlePtr
  404. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineSingleLV2)
  405. };
  406. CARLA_BACKEND_END_NAMESPACE
  407. using CarlaBackend::CarlaEngineSingleLV2;
  408. // --------------------------------------------------------------------------------------------------------------------
  409. // LV2 DSP functions
  410. static LV2_Handle lv2_instantiate(const LV2_Descriptor* lv2Descriptor, double sampleRate, const char* bundlePath, const LV2_Feature* const* features)
  411. {
  412. carla_stdout("lv2_instantiate(%p, %g, %s, %p)", lv2Descriptor, sampleRate, bundlePath, features);
  413. CarlaEngineSingleLV2* const instance(new CarlaEngineSingleLV2(sampleRate, bundlePath, features));
  414. if (instance->hasPlugin())
  415. return (LV2_Handle)instance;
  416. delete instance;
  417. return nullptr;
  418. }
  419. #define instancePtr ((CarlaEngineSingleLV2*)instance)
  420. static void lv2_connect_port(LV2_Handle instance, uint32_t port, void* dataLocation)
  421. {
  422. instancePtr->lv2_connect_port(port, dataLocation);
  423. }
  424. static void lv2_activate(LV2_Handle instance)
  425. {
  426. carla_debug("lv2_activate(%p)", instance);
  427. instancePtr->lv2_activate();
  428. }
  429. static void lv2_run(LV2_Handle instance, uint32_t sampleCount)
  430. {
  431. instancePtr->lv2_run(sampleCount);
  432. }
  433. static void lv2_deactivate(LV2_Handle instance)
  434. {
  435. carla_debug("lv2_deactivate(%p)", instance);
  436. instancePtr->lv2_deactivate();
  437. }
  438. static void lv2_cleanup(LV2_Handle instance)
  439. {
  440. carla_debug("lv2_cleanup(%p)", instance);
  441. delete instancePtr;
  442. }
  443. static const void* lv2_extension_data(const char* uri)
  444. {
  445. carla_debug("lv2_extension_data(\"%s\")", uri);
  446. return nullptr;
  447. // unused
  448. (void)uri;
  449. }
  450. #undef instancePtr
  451. // --------------------------------------------------------------------------------------------------------------------
  452. // LV2 UI functions
  453. static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const char*, const char*,
  454. LV2UI_Write_Function writeFunction, LV2UI_Controller controller,
  455. LV2UI_Widget* widget, const LV2_Feature* const* features)
  456. {
  457. carla_debug("lv2ui_instantiate(..., %p, %p, %p)", writeFunction, controller, widget, features);
  458. CarlaEngineSingleLV2* engine = nullptr;
  459. for (int i=0; features[i] != nullptr; ++i)
  460. {
  461. if (std::strcmp(features[i]->URI, LV2_INSTANCE_ACCESS_URI) == 0)
  462. {
  463. engine = (CarlaEngineSingleLV2*)features[i]->data;
  464. break;
  465. }
  466. }
  467. if (engine == nullptr)
  468. {
  469. carla_stderr("Host doesn't support instance-access, cannot show UI");
  470. return nullptr;
  471. }
  472. if (! engine->lv2ui_instantiate(writeFunction, controller, widget, features))
  473. return nullptr;
  474. return (LV2UI_Handle)engine;
  475. }
  476. #define uiPtr ((CarlaEngineSingleLV2*)ui)
  477. static void lv2ui_port_event(LV2UI_Handle ui, uint32_t portIndex, uint32_t bufferSize, uint32_t format, const void* buffer)
  478. {
  479. carla_debug("lv2ui_port_event(%p, %i, %i, %i, %p)", ui, portIndex, bufferSize, format, buffer);
  480. uiPtr->lv2ui_port_event(portIndex, bufferSize, format, buffer);
  481. }
  482. static void lv2ui_cleanup(LV2UI_Handle ui)
  483. {
  484. carla_debug("lv2ui_cleanup(%p)", ui);
  485. uiPtr->lv2ui_cleanup();
  486. }
  487. static int lv2ui_idle(LV2UI_Handle ui)
  488. {
  489. return uiPtr->lv2ui_idle();
  490. }
  491. static int lv2ui_show(LV2UI_Handle ui)
  492. {
  493. carla_debug("lv2ui_show(%p)", ui);
  494. return uiPtr->lv2ui_show();
  495. }
  496. static int lv2ui_hide(LV2UI_Handle ui)
  497. {
  498. carla_debug("lv2ui_hide(%p)", ui);
  499. return uiPtr->lv2ui_hide();
  500. }
  501. static const void* lv2ui_extension_data(const char* uri)
  502. {
  503. carla_debug("lv2ui_extension_data(\"%s\")", uri);
  504. static const LV2UI_Idle_Interface uiidle = { lv2ui_idle };
  505. static const LV2UI_Show_Interface uishow = { lv2ui_show, lv2ui_hide };
  506. if (std::strcmp(uri, LV2_UI__idleInterface) == 0)
  507. return &uiidle;
  508. if (std::strcmp(uri, LV2_UI__showInterface) == 0)
  509. return &uishow;
  510. return nullptr;
  511. }
  512. #undef uiPtr
  513. // --------------------------------------------------------------------------------------------------------------------
  514. // Startup code
  515. CARLA_EXPORT
  516. const LV2_Descriptor* lv2_descriptor(uint32_t index)
  517. {
  518. carla_stdout("lv2_descriptor(%i)", index);
  519. if (index != 0)
  520. return nullptr;
  521. static CarlaString ret;
  522. if (ret.isEmpty())
  523. {
  524. using namespace water;
  525. const File file(File::getSpecialLocation(File::currentExecutableFile).withFileExtension("ttl"));
  526. ret = String("file://" + file.getFullPathName()).toRawUTF8();
  527. }
  528. static const LV2_Descriptor desc = {
  529. /* URI */ ret.buffer(),
  530. /* instantiate */ lv2_instantiate,
  531. /* connect_port */ lv2_connect_port,
  532. /* activate */ lv2_activate,
  533. /* run */ lv2_run,
  534. /* deactivate */ lv2_deactivate,
  535. /* cleanup */ lv2_cleanup,
  536. /* extension_data */ lv2_extension_data
  537. };
  538. return &desc;
  539. }
  540. CARLA_EXPORT
  541. const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index)
  542. {
  543. carla_stdout("lv2ui_descriptor(%i)", index);
  544. static CarlaString ret;
  545. if (ret.isEmpty())
  546. {
  547. using namespace water;
  548. const File file(File::getSpecialLocation(File::currentExecutableFile).getSiblingFile("ext-ui"));
  549. ret = String("file://" + file.getFullPathName()).toRawUTF8();
  550. }
  551. static const LV2UI_Descriptor lv2UiExtDesc = {
  552. /* URI */ ret.buffer(),
  553. /* instantiate */ lv2ui_instantiate,
  554. /* cleanup */ lv2ui_cleanup,
  555. /* port_event */ lv2ui_port_event,
  556. /* extension_data */ lv2ui_extension_data
  557. };
  558. return (index == 0) ? &lv2UiExtDesc : nullptr;
  559. }
  560. // --------------------------------------------------------------------------------------------------------------------