The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

759 lines
26KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. #if JUCE_ALSA
  20. //==============================================================================
  21. class AlsaClient : public ReferenceCountedObject
  22. {
  23. public:
  24. ~AlsaClient()
  25. {
  26. inputThread.reset();
  27. jassert (instance != nullptr);
  28. instance = nullptr;
  29. jassert (activeCallbacks.get() == 0);
  30. if (handle != nullptr)
  31. {
  32. snd_seq_delete_simple_port (handle, announcementsIn);
  33. snd_seq_close (handle);
  34. }
  35. }
  36. static String getAlsaMidiName()
  37. {
  38. #ifdef JUCE_ALSA_MIDI_NAME
  39. return JUCE_ALSA_MIDI_NAME;
  40. #else
  41. if (auto* app = JUCEApplicationBase::getInstance())
  42. return app->getApplicationName();
  43. return "JUCE";
  44. #endif
  45. }
  46. using Ptr = ReferenceCountedObjectPtr<AlsaClient>;
  47. //==============================================================================
  48. // represents an input or output port of the supplied AlsaClient
  49. struct Port
  50. {
  51. Port (AlsaClient& c, bool forInput) noexcept
  52. : client (c), isInput (forInput)
  53. {}
  54. ~Port()
  55. {
  56. if (isValid())
  57. {
  58. if (isInput)
  59. enableCallback (false);
  60. else
  61. snd_midi_event_free (midiParser);
  62. snd_seq_delete_simple_port (client.get(), portId);
  63. }
  64. }
  65. void connectWith (int sourceClient, int sourcePort) const noexcept
  66. {
  67. if (isInput)
  68. snd_seq_connect_from (client.get(), portId, sourceClient, sourcePort);
  69. else
  70. snd_seq_connect_to (client.get(), portId, sourceClient, sourcePort);
  71. }
  72. bool isValid() const noexcept
  73. {
  74. return client.get() != nullptr && portId >= 0;
  75. }
  76. void setupInput (MidiInput* input, MidiInputCallback* cb)
  77. {
  78. jassert (cb != nullptr && input != nullptr);
  79. callback = cb;
  80. midiInput = input;
  81. }
  82. void setupOutput()
  83. {
  84. jassert (! isInput);
  85. snd_midi_event_new ((size_t) maxEventSize, &midiParser);
  86. }
  87. void enableCallback (bool enable)
  88. {
  89. callbackEnabled = enable;
  90. }
  91. bool sendMessageNow (const MidiMessage& message)
  92. {
  93. if (message.getRawDataSize() > maxEventSize)
  94. {
  95. maxEventSize = message.getRawDataSize();
  96. snd_midi_event_free (midiParser);
  97. snd_midi_event_new ((size_t) maxEventSize, &midiParser);
  98. }
  99. snd_seq_event_t event;
  100. snd_seq_ev_clear (&event);
  101. auto numBytes = (long) message.getRawDataSize();
  102. auto* data = message.getRawData();
  103. auto seqHandle = client.get();
  104. bool success = true;
  105. while (numBytes > 0)
  106. {
  107. auto numSent = snd_midi_event_encode (midiParser, data, numBytes, &event);
  108. if (numSent <= 0)
  109. {
  110. success = numSent == 0;
  111. break;
  112. }
  113. numBytes -= numSent;
  114. data += numSent;
  115. snd_seq_ev_set_source (&event, (unsigned char) portId);
  116. snd_seq_ev_set_subs (&event);
  117. snd_seq_ev_set_direct (&event);
  118. if (snd_seq_event_output_direct (seqHandle, &event) < 0)
  119. {
  120. success = false;
  121. break;
  122. }
  123. }
  124. snd_midi_event_reset_encode (midiParser);
  125. return success;
  126. }
  127. bool operator== (const Port& lhs) const noexcept
  128. {
  129. return portId != -1 && portId == lhs.portId;
  130. }
  131. void createPort (const String& name, bool enableSubscription)
  132. {
  133. if (auto seqHandle = client.get())
  134. {
  135. const unsigned int caps =
  136. isInput ? (SND_SEQ_PORT_CAP_WRITE | (enableSubscription ? SND_SEQ_PORT_CAP_SUBS_WRITE : 0))
  137. : (SND_SEQ_PORT_CAP_READ | (enableSubscription ? SND_SEQ_PORT_CAP_SUBS_READ : 0));
  138. portName = name;
  139. portId = snd_seq_create_simple_port (seqHandle, portName.toUTF8(), caps,
  140. SND_SEQ_PORT_TYPE_MIDI_GENERIC |
  141. SND_SEQ_PORT_TYPE_APPLICATION);
  142. }
  143. }
  144. void handleIncomingMidiMessage (const MidiMessage& message) const
  145. {
  146. if (callbackEnabled)
  147. callback->handleIncomingMidiMessage (midiInput, message);
  148. }
  149. void handlePartialSysexMessage (const uint8* messageData, int numBytesSoFar, double timeStamp)
  150. {
  151. if (callbackEnabled)
  152. callback->handlePartialSysexMessage (midiInput, messageData, numBytesSoFar, timeStamp);
  153. }
  154. int getPortId() const { return portId; }
  155. const String& getPortName() const { return portName; }
  156. private:
  157. AlsaClient& client;
  158. MidiInputCallback* callback = nullptr;
  159. snd_midi_event_t* midiParser = nullptr;
  160. MidiInput* midiInput = nullptr;
  161. String portName;
  162. int maxEventSize = 4096, portId = -1;
  163. std::atomic<bool> callbackEnabled { false };
  164. bool isInput = false;
  165. };
  166. static Ptr getInstance()
  167. {
  168. if (instance == nullptr)
  169. instance = new AlsaClient();
  170. return instance;
  171. }
  172. void handleIncomingMidiMessage (snd_seq_event* event, const MidiMessage& message)
  173. {
  174. const ScopedLock sl (callbackLock);
  175. if (auto* port = ports[event->dest.port])
  176. port->handleIncomingMidiMessage (message);
  177. }
  178. void handlePartialSysexMessage (snd_seq_event* event, const uint8* messageData, int numBytesSoFar, double timeStamp)
  179. {
  180. const ScopedLock sl (callbackLock);
  181. if (auto* port = ports[event->dest.port])
  182. port->handlePartialSysexMessage (messageData, numBytesSoFar, timeStamp);
  183. }
  184. snd_seq_t* get() const noexcept { return handle; }
  185. int getId() const noexcept { return clientId; }
  186. Port* createPort (const String& name, bool forInput, bool enableSubscription)
  187. {
  188. const ScopedLock sl (callbackLock);
  189. auto port = new Port (*this, forInput);
  190. port->createPort (name, enableSubscription);
  191. ports.set (port->getPortId(), port);
  192. incReferenceCount();
  193. return port;
  194. }
  195. void deletePort (Port* port)
  196. {
  197. const ScopedLock sl (callbackLock);
  198. ports.set (port->getPortId(), nullptr);
  199. decReferenceCount();
  200. }
  201. private:
  202. AlsaClient()
  203. {
  204. jassert (instance == nullptr);
  205. snd_seq_open (&handle, "default", SND_SEQ_OPEN_DUPLEX, 0);
  206. if (handle != nullptr)
  207. {
  208. snd_seq_nonblock (handle, SND_SEQ_NONBLOCK);
  209. snd_seq_set_client_name (handle, getAlsaMidiName().toRawUTF8());
  210. clientId = snd_seq_client_id (handle);
  211. // It's good idea to pre-allocate a good number of elements
  212. ports.ensureStorageAllocated (32);
  213. announcementsIn = snd_seq_create_simple_port (handle,
  214. TRANS ("announcements").toRawUTF8(),
  215. SND_SEQ_PORT_CAP_WRITE,
  216. SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION);
  217. snd_seq_connect_from (handle, announcementsIn, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_ANNOUNCE);
  218. inputThread.emplace (*this);
  219. }
  220. }
  221. snd_seq_t* handle = nullptr;
  222. int clientId = 0;
  223. int announcementsIn = 0;
  224. OwnedArray<Port> ports;
  225. Atomic<int> activeCallbacks;
  226. CriticalSection callbackLock;
  227. static AlsaClient* instance;
  228. //==============================================================================
  229. class SequencerThread
  230. {
  231. public:
  232. explicit SequencerThread (AlsaClient& c)
  233. : client (c)
  234. {
  235. }
  236. ~SequencerThread() noexcept
  237. {
  238. shouldStop = true;
  239. thread.join();
  240. }
  241. private:
  242. // If we directly call MidiDeviceListConnectionBroadcaster::get() from the background thread,
  243. // there's a possibility that we'll deadlock in the following scenario:
  244. // - The main thread calls MidiDeviceListConnectionBroadcaster::get() for the first time
  245. // (e.g. to register a listener). The static MidiDeviceListConnectionBroadcaster singleton
  246. // begins construction. During the constructor, an AlsaClient is created to iterate midi
  247. // ins/outs.
  248. // - The AlsaClient starts a new SequencerThread. If connections are updated, the
  249. // SequencerThread may call MidiDeviceListConnectionBroadcaster::get().notify()
  250. // while the MidiDeviceListConnectionBroadcaster singleton is still being created.
  251. // - The SequencerThread blocks until the MidiDeviceListConnectionBroadcaster has been
  252. // created on the main thread, but the MidiDeviceListConnectionBroadcaster's constructor
  253. // can't complete until the AlsaClient's destructor has run, which in turn requires the
  254. // SequencerThread to join.
  255. class UpdateNotifier : private AsyncUpdater
  256. {
  257. public:
  258. ~UpdateNotifier() override { cancelPendingUpdate(); }
  259. using AsyncUpdater::triggerAsyncUpdate;
  260. private:
  261. void handleAsyncUpdate() override { MidiDeviceListConnectionBroadcaster::get().notify(); }
  262. };
  263. AlsaClient& client;
  264. MidiDataConcatenator concatenator { 2048 };
  265. std::atomic<bool> shouldStop { false };
  266. UpdateNotifier notifier;
  267. std::thread thread { [this]
  268. {
  269. Thread::setCurrentThreadName ("JUCE MIDI Input");
  270. auto seqHandle = client.get();
  271. const int maxEventSize = 16 * 1024;
  272. snd_midi_event_t* midiParser;
  273. if (snd_midi_event_new (maxEventSize, &midiParser) >= 0)
  274. {
  275. const ScopeGuard freeMidiEvent { [&] { snd_midi_event_free (midiParser); } };
  276. const auto numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN);
  277. std::vector<pollfd> pfd (static_cast<size_t> (numPfds));
  278. snd_seq_poll_descriptors (seqHandle, pfd.data(), (unsigned int) numPfds, POLLIN);
  279. std::vector<uint8> buffer (maxEventSize);
  280. while (! shouldStop)
  281. {
  282. // This timeout shouldn't be too long, so that the program can exit in a timely manner
  283. if (poll (pfd.data(), (nfds_t) numPfds, 100) > 0)
  284. {
  285. if (shouldStop)
  286. break;
  287. do
  288. {
  289. snd_seq_event_t* inputEvent = nullptr;
  290. if (snd_seq_event_input (seqHandle, &inputEvent) >= 0)
  291. {
  292. const ScopeGuard freeInputEvent { [&] { snd_seq_free_event (inputEvent); } };
  293. constexpr int systemEvents[]
  294. {
  295. SND_SEQ_EVENT_CLIENT_CHANGE,
  296. SND_SEQ_EVENT_CLIENT_START,
  297. SND_SEQ_EVENT_CLIENT_EXIT,
  298. SND_SEQ_EVENT_PORT_CHANGE,
  299. SND_SEQ_EVENT_PORT_START,
  300. SND_SEQ_EVENT_PORT_EXIT,
  301. SND_SEQ_EVENT_PORT_SUBSCRIBED,
  302. SND_SEQ_EVENT_PORT_UNSUBSCRIBED,
  303. };
  304. const auto foundEvent = std::find (std::begin (systemEvents),
  305. std::end (systemEvents),
  306. inputEvent->type);
  307. if (foundEvent != std::end (systemEvents))
  308. {
  309. notifier.triggerAsyncUpdate();
  310. continue;
  311. }
  312. // xxx what about SYSEXes that are too big for the buffer?
  313. const auto numBytes = snd_midi_event_decode (midiParser,
  314. buffer.data(),
  315. maxEventSize,
  316. inputEvent);
  317. snd_midi_event_reset_decode (midiParser);
  318. concatenator.pushMidiData (buffer.data(), (int) numBytes,
  319. Time::getMillisecondCounter() * 0.001,
  320. inputEvent, client);
  321. }
  322. }
  323. while (snd_seq_event_input_pending (seqHandle, 0) > 0);
  324. }
  325. }
  326. }
  327. } };
  328. };
  329. std::optional<SequencerThread> inputThread;
  330. };
  331. AlsaClient* AlsaClient::instance = nullptr;
  332. //==============================================================================
  333. static String getFormattedPortIdentifier (int clientId, int portId)
  334. {
  335. return String (clientId) + "-" + String (portId);
  336. }
  337. static AlsaClient::Port* iterateMidiClient (const AlsaClient::Ptr& client,
  338. snd_seq_client_info_t* clientInfo,
  339. bool forInput,
  340. Array<MidiDeviceInfo>& devices,
  341. const String& deviceIdentifierToOpen)
  342. {
  343. AlsaClient::Port* port = nullptr;
  344. auto seqHandle = client->get();
  345. snd_seq_port_info_t* portInfo = nullptr;
  346. snd_seq_port_info_alloca (&portInfo);
  347. jassert (portInfo != nullptr);
  348. auto numPorts = snd_seq_client_info_get_num_ports (clientInfo);
  349. auto sourceClient = snd_seq_client_info_get_client (clientInfo);
  350. snd_seq_port_info_set_client (portInfo, sourceClient);
  351. snd_seq_port_info_set_port (portInfo, -1);
  352. while (--numPorts >= 0)
  353. {
  354. if (snd_seq_query_next_port (seqHandle, portInfo) == 0
  355. && (snd_seq_port_info_get_capability (portInfo)
  356. & (forInput ? SND_SEQ_PORT_CAP_SUBS_READ : SND_SEQ_PORT_CAP_SUBS_WRITE)) != 0)
  357. {
  358. String portName (snd_seq_port_info_get_name (portInfo));
  359. auto portID = snd_seq_port_info_get_port (portInfo);
  360. MidiDeviceInfo device (portName, getFormattedPortIdentifier (sourceClient, portID));
  361. devices.add (device);
  362. if (deviceIdentifierToOpen.isNotEmpty() && deviceIdentifierToOpen == device.identifier)
  363. {
  364. if (portID != -1)
  365. {
  366. port = client->createPort (portName, forInput, false);
  367. jassert (port->isValid());
  368. port->connectWith (sourceClient, portID);
  369. break;
  370. }
  371. }
  372. }
  373. }
  374. return port;
  375. }
  376. static AlsaClient::Port* iterateMidiDevices (bool forInput,
  377. Array<MidiDeviceInfo>& devices,
  378. const String& deviceIdentifierToOpen)
  379. {
  380. AlsaClient::Port* port = nullptr;
  381. auto client = AlsaClient::getInstance();
  382. if (auto seqHandle = client->get())
  383. {
  384. snd_seq_system_info_t* systemInfo = nullptr;
  385. snd_seq_client_info_t* clientInfo = nullptr;
  386. snd_seq_system_info_alloca (&systemInfo);
  387. jassert (systemInfo != nullptr);
  388. if (snd_seq_system_info (seqHandle, systemInfo) == 0)
  389. {
  390. snd_seq_client_info_alloca (&clientInfo);
  391. jassert (clientInfo != nullptr);
  392. auto numClients = snd_seq_system_info_get_cur_clients (systemInfo);
  393. while (--numClients >= 0)
  394. {
  395. if (snd_seq_query_next_client (seqHandle, clientInfo) == 0)
  396. {
  397. port = iterateMidiClient (client, clientInfo, forInput,
  398. devices, deviceIdentifierToOpen);
  399. if (port != nullptr)
  400. break;
  401. }
  402. }
  403. }
  404. }
  405. return port;
  406. }
  407. struct AlsaPortPtr
  408. {
  409. explicit AlsaPortPtr (AlsaClient::Port* p)
  410. : ptr (p) {}
  411. ~AlsaPortPtr() noexcept { AlsaClient::getInstance()->deletePort (ptr); }
  412. AlsaClient::Port* ptr = nullptr;
  413. };
  414. //==============================================================================
  415. class MidiInput::Pimpl : public AlsaPortPtr
  416. {
  417. public:
  418. using AlsaPortPtr::AlsaPortPtr;
  419. };
  420. Array<MidiDeviceInfo> MidiInput::getAvailableDevices()
  421. {
  422. Array<MidiDeviceInfo> devices;
  423. iterateMidiDevices (true, devices, {});
  424. return devices;
  425. }
  426. MidiDeviceInfo MidiInput::getDefaultDevice()
  427. {
  428. return getAvailableDevices().getFirst();
  429. }
  430. std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier, MidiInputCallback* callback)
  431. {
  432. if (deviceIdentifier.isEmpty())
  433. return {};
  434. Array<MidiDeviceInfo> devices;
  435. auto* port = iterateMidiDevices (true, devices, deviceIdentifier);
  436. if (port == nullptr || ! port->isValid())
  437. return {};
  438. jassert (port->isValid());
  439. std::unique_ptr<MidiInput> midiInput (new MidiInput (port->getPortName(), deviceIdentifier));
  440. port->setupInput (midiInput.get(), callback);
  441. midiInput->internal = std::make_unique<Pimpl> (port);
  442. return midiInput;
  443. }
  444. std::unique_ptr<MidiInput> MidiInput::createNewDevice (const String& deviceName, MidiInputCallback* callback)
  445. {
  446. auto client = AlsaClient::getInstance();
  447. auto* port = client->createPort (deviceName, true, true);
  448. if (port == nullptr || ! port->isValid())
  449. return {};
  450. std::unique_ptr<MidiInput> midiInput (new MidiInput (deviceName, getFormattedPortIdentifier (client->getId(), port->getPortId())));
  451. port->setupInput (midiInput.get(), callback);
  452. midiInput->internal = std::make_unique<Pimpl> (port);
  453. return midiInput;
  454. }
  455. StringArray MidiInput::getDevices()
  456. {
  457. StringArray deviceNames;
  458. for (auto& d : getAvailableDevices())
  459. deviceNames.add (d.name);
  460. deviceNames.appendNumbersToDuplicates (true, true);
  461. return deviceNames;
  462. }
  463. int MidiInput::getDefaultDeviceIndex()
  464. {
  465. return 0;
  466. }
  467. std::unique_ptr<MidiInput> MidiInput::openDevice (int index, MidiInputCallback* callback)
  468. {
  469. return openDevice (getAvailableDevices()[index].identifier, callback);
  470. }
  471. MidiInput::MidiInput (const String& deviceName, const String& deviceIdentifier)
  472. : deviceInfo (deviceName, deviceIdentifier)
  473. {
  474. }
  475. MidiInput::~MidiInput()
  476. {
  477. stop();
  478. }
  479. void MidiInput::start()
  480. {
  481. internal->ptr->enableCallback (true);
  482. }
  483. void MidiInput::stop()
  484. {
  485. internal->ptr->enableCallback (false);
  486. }
  487. //==============================================================================
  488. class MidiOutput::Pimpl : public AlsaPortPtr
  489. {
  490. public:
  491. using AlsaPortPtr::AlsaPortPtr;
  492. };
  493. Array<MidiDeviceInfo> MidiOutput::getAvailableDevices()
  494. {
  495. Array<MidiDeviceInfo> devices;
  496. iterateMidiDevices (false, devices, {});
  497. return devices;
  498. }
  499. MidiDeviceInfo MidiOutput::getDefaultDevice()
  500. {
  501. return getAvailableDevices().getFirst();
  502. }
  503. std::unique_ptr<MidiOutput> MidiOutput::openDevice (const String& deviceIdentifier)
  504. {
  505. if (deviceIdentifier.isEmpty())
  506. return {};
  507. Array<MidiDeviceInfo> devices;
  508. auto* port = iterateMidiDevices (false, devices, deviceIdentifier);
  509. if (port == nullptr || ! port->isValid())
  510. return {};
  511. std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (port->getPortName(), deviceIdentifier));
  512. port->setupOutput();
  513. midiOutput->internal = std::make_unique<Pimpl> (port);
  514. return midiOutput;
  515. }
  516. std::unique_ptr<MidiOutput> MidiOutput::createNewDevice (const String& deviceName)
  517. {
  518. auto client = AlsaClient::getInstance();
  519. auto* port = client->createPort (deviceName, false, true);
  520. if (port == nullptr || ! port->isValid())
  521. return {};
  522. std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (deviceName, getFormattedPortIdentifier (client->getId(), port->getPortId())));
  523. port->setupOutput();
  524. midiOutput->internal = std::make_unique<Pimpl> (port);
  525. return midiOutput;
  526. }
  527. StringArray MidiOutput::getDevices()
  528. {
  529. StringArray deviceNames;
  530. for (auto& d : getAvailableDevices())
  531. deviceNames.add (d.name);
  532. deviceNames.appendNumbersToDuplicates (true, true);
  533. return deviceNames;
  534. }
  535. int MidiOutput::getDefaultDeviceIndex()
  536. {
  537. return 0;
  538. }
  539. std::unique_ptr<MidiOutput> MidiOutput::openDevice (int index)
  540. {
  541. return openDevice (getAvailableDevices()[index].identifier);
  542. }
  543. MidiOutput::~MidiOutput()
  544. {
  545. stopBackgroundThread();
  546. }
  547. void MidiOutput::sendMessageNow (const MidiMessage& message)
  548. {
  549. internal->ptr->sendMessageNow (message);
  550. }
  551. MidiDeviceListConnection MidiDeviceListConnection::make (std::function<void()> cb)
  552. {
  553. auto& broadcaster = MidiDeviceListConnectionBroadcaster::get();
  554. // We capture the AlsaClient instance here to ensure that it remains alive for at least as long
  555. // as the MidiDeviceListConnection. This is necessary because system change messages will only
  556. // be processed when the AlsaClient's SequencerThread is running.
  557. return { &broadcaster, broadcaster.add ([fn = std::move (cb), client = AlsaClient::getInstance()]
  558. {
  559. NullCheckedInvocation::invoke (fn);
  560. }) };
  561. }
  562. //==============================================================================
  563. #else
  564. class MidiInput::Pimpl {};
  565. // (These are just stub functions if ALSA is unavailable...)
  566. MidiInput::MidiInput (const String& deviceName, const String& deviceID)
  567. : deviceInfo (deviceName, deviceID)
  568. {
  569. }
  570. MidiInput::~MidiInput() {}
  571. void MidiInput::start() {}
  572. void MidiInput::stop() {}
  573. Array<MidiDeviceInfo> MidiInput::getAvailableDevices() { return {}; }
  574. MidiDeviceInfo MidiInput::getDefaultDevice() { return {}; }
  575. std::unique_ptr<MidiInput> MidiInput::openDevice (const String&, MidiInputCallback*) { return {}; }
  576. std::unique_ptr<MidiInput> MidiInput::createNewDevice (const String&, MidiInputCallback*) { return {}; }
  577. StringArray MidiInput::getDevices() { return {}; }
  578. int MidiInput::getDefaultDeviceIndex() { return 0;}
  579. std::unique_ptr<MidiInput> MidiInput::openDevice (int, MidiInputCallback*) { return {}; }
  580. class MidiOutput::Pimpl {};
  581. MidiOutput::~MidiOutput() {}
  582. void MidiOutput::sendMessageNow (const MidiMessage&) {}
  583. Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() { return {}; }
  584. MidiDeviceInfo MidiOutput::getDefaultDevice() { return {}; }
  585. std::unique_ptr<MidiOutput> MidiOutput::openDevice (const String&) { return {}; }
  586. std::unique_ptr<MidiOutput> MidiOutput::createNewDevice (const String&) { return {}; }
  587. StringArray MidiOutput::getDevices() { return {}; }
  588. int MidiOutput::getDefaultDeviceIndex() { return 0;}
  589. std::unique_ptr<MidiOutput> MidiOutput::openDevice (int) { return {}; }
  590. MidiDeviceListConnection MidiDeviceListConnection::make (std::function<void()> cb)
  591. {
  592. auto& broadcaster = MidiDeviceListConnectionBroadcaster::get();
  593. return { &broadcaster, broadcaster.add (std::move (cb)) };
  594. }
  595. #endif
  596. } // namespace juce