jack2 codebase
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.

684 lines
23KB

  1. /*
  2. Copyright (C) 2009 Grame
  3. Copyright (C) 2011 Devin Anderson
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include <stdexcept>
  17. #include <mach/mach_time.h>
  18. #include "JackCoreMidiDriver.h"
  19. #include "JackCoreMidiUtil.h"
  20. #include "JackEngineControl.h"
  21. using Jack::JackCoreMidiDriver;
  22. ///////////////////////////////////////////////////////////////////////////////
  23. // Static callbacks
  24. ///////////////////////////////////////////////////////////////////////////////
  25. void
  26. JackCoreMidiDriver::HandleInputEvent(const MIDIPacketList *packet_list,
  27. void *driver, void *port)
  28. {
  29. ((JackCoreMidiPhysicalInputPort *) port)->ProcessCoreMidi(packet_list);
  30. }
  31. void
  32. JackCoreMidiDriver::HandleNotificationEvent(const MIDINotification *message,
  33. void *driver)
  34. {
  35. ((JackCoreMidiDriver *) driver)->HandleNotification(message);
  36. }
  37. ///////////////////////////////////////////////////////////////////////////////
  38. // Class
  39. ///////////////////////////////////////////////////////////////////////////////
  40. JackCoreMidiDriver::JackCoreMidiDriver(const char *name, const char *alias,
  41. JackLockedEngine *engine,
  42. JackSynchro *table):
  43. JackMidiDriver(name, alias, engine, table)
  44. {
  45. mach_timebase_info_data_t info;
  46. kern_return_t result = mach_timebase_info(&info);
  47. if (result != KERN_SUCCESS) {
  48. throw std::runtime_error(mach_error_string(result));
  49. }
  50. client = 0;
  51. fCaptureChannels = 0;
  52. fPlaybackChannels = 0;
  53. num_physical_inputs = 0;
  54. num_physical_outputs = 0;
  55. num_virtual_inputs = 0;
  56. num_virtual_outputs = 0;
  57. physical_input_ports = 0;
  58. physical_output_ports = 0;
  59. time_ratio = (((double) info.numer) / info.denom) / 1000.0;
  60. virtual_input_ports = 0;
  61. virtual_output_ports = 0;
  62. }
  63. JackCoreMidiDriver::~JackCoreMidiDriver()
  64. {}
  65. int
  66. JackCoreMidiDriver::Attach()
  67. {
  68. jack_nframes_t buffer_size = fEngineControl->fBufferSize;
  69. jack_port_id_t index;
  70. jack_nframes_t latency = buffer_size;
  71. jack_latency_range_t latency_range;
  72. const char *name;
  73. JackPort *port;
  74. JackCoreMidiPort *port_obj;
  75. latency_range.max = latency;
  76. latency_range.min = latency;
  77. // Physical inputs
  78. for (int i = 0; i < num_physical_inputs; i++) {
  79. port_obj = physical_input_ports[i];
  80. name = port_obj->GetName();
  81. if (fEngine->PortRegister(fClientControl.fRefNum, name,
  82. JACK_DEFAULT_MIDI_TYPE,
  83. CaptureDriverFlags, buffer_size, &index) < 0) {
  84. jack_error("JackCoreMidiDriver::Attach - cannot register physical "
  85. "input port with name '%s'.", name);
  86. // X: Do we need to deallocate ports?
  87. return -1;
  88. }
  89. port = fGraphManager->GetPort(index);
  90. port->SetAlias(port_obj->GetAlias());
  91. port->SetLatencyRange(JackCaptureLatency, &latency_range);
  92. fCapturePortList[i] = index;
  93. }
  94. // Virtual inputs
  95. for (int i = 0; i < num_virtual_inputs; i++) {
  96. port_obj = virtual_input_ports[i];
  97. name = port_obj->GetName();
  98. if (fEngine->PortRegister(fClientControl.fRefNum, name,
  99. JACK_DEFAULT_MIDI_TYPE,
  100. CaptureDriverFlags, buffer_size, &index) < 0) {
  101. jack_error("JackCoreMidiDriver::Attach - cannot register virtual "
  102. "input port with name '%s'.", name);
  103. // X: Do we need to deallocate ports?
  104. return -1;
  105. }
  106. port = fGraphManager->GetPort(index);
  107. port->SetAlias(port_obj->GetAlias());
  108. port->SetLatencyRange(JackCaptureLatency, &latency_range);
  109. fCapturePortList[num_physical_inputs + i] = index;
  110. }
  111. if (! fEngineControl->fSyncMode) {
  112. latency += buffer_size;
  113. latency_range.max = latency;
  114. latency_range.min = latency;
  115. }
  116. // Physical outputs
  117. for (int i = 0; i < num_physical_outputs; i++) {
  118. port_obj = physical_output_ports[i];
  119. name = port_obj->GetName();
  120. fEngine->PortRegister(fClientControl.fRefNum, name,
  121. JACK_DEFAULT_MIDI_TYPE,
  122. PlaybackDriverFlags, buffer_size, &index);
  123. if (index == NO_PORT) {
  124. jack_error("JackCoreMidiDriver::Attach - cannot register physical "
  125. "output port with name '%s'.", name);
  126. // X: Do we need to deallocate ports?
  127. return -1;
  128. }
  129. port = fGraphManager->GetPort(index);
  130. port->SetAlias(port_obj->GetAlias());
  131. port->SetLatencyRange(JackPlaybackLatency, &latency_range);
  132. fPlaybackPortList[i] = index;
  133. }
  134. // Virtual outputs
  135. for (int i = 0; i < num_virtual_outputs; i++) {
  136. port_obj = virtual_output_ports[i];
  137. name = port_obj->GetName();
  138. fEngine->PortRegister(fClientControl.fRefNum, name,
  139. JACK_DEFAULT_MIDI_TYPE,
  140. PlaybackDriverFlags, buffer_size, &index);
  141. if (index == NO_PORT) {
  142. jack_error("JackCoreMidiDriver::Attach - cannot register virtual "
  143. "output port with name '%s'.", name);
  144. // X: Do we need to deallocate ports?
  145. return -1;
  146. }
  147. port = fGraphManager->GetPort(index);
  148. port->SetAlias(port_obj->GetAlias());
  149. port->SetLatencyRange(JackPlaybackLatency, &latency_range);
  150. fPlaybackPortList[num_physical_outputs + i] = index;
  151. }
  152. return 0;
  153. }
  154. int
  155. JackCoreMidiDriver::Close()
  156. {
  157. // Generic MIDI driver close
  158. int result = JackMidiDriver::Close();
  159. OSStatus status;
  160. if (physical_input_ports) {
  161. for (int i = 0; i < num_physical_inputs; i++) {
  162. delete physical_input_ports[i];
  163. }
  164. delete[] physical_input_ports;
  165. num_physical_inputs = 0;
  166. physical_input_ports = 0;
  167. status = MIDIPortDispose(internal_input);
  168. if (status != noErr) {
  169. WriteMacOSError("JackCoreMidiDriver::Close", "MIDIPortDispose",
  170. status);
  171. result = -1;
  172. }
  173. }
  174. if (physical_output_ports) {
  175. for (int i = 0; i < num_physical_outputs; i++) {
  176. delete physical_output_ports[i];
  177. }
  178. delete[] physical_output_ports;
  179. num_physical_outputs = 0;
  180. physical_output_ports = 0;
  181. status = MIDIPortDispose(internal_output);
  182. if (status != noErr) {
  183. WriteMacOSError("JackCoreMidiDriver::Close", "MIDIPortDispose",
  184. status);
  185. result = -1;
  186. }
  187. }
  188. if (virtual_input_ports) {
  189. for (int i = 0; i < num_virtual_inputs; i++) {
  190. delete virtual_input_ports[i];
  191. }
  192. delete[] virtual_input_ports;
  193. num_virtual_inputs = 0;
  194. virtual_input_ports = 0;
  195. }
  196. if (virtual_output_ports) {
  197. for (int i = 0; i < num_virtual_outputs; i++) {
  198. delete virtual_output_ports[i];
  199. }
  200. delete[] virtual_output_ports;
  201. num_virtual_outputs = 0;
  202. virtual_output_ports = 0;
  203. }
  204. if (client) {
  205. status = MIDIClientDispose(client);
  206. if (status != noErr) {
  207. WriteMacOSError("JackCoreMidiDriver::Close", "MIDIClientDispose",
  208. status);
  209. result = -1;
  210. }
  211. client = 0;
  212. }
  213. return result;
  214. }
  215. void
  216. JackCoreMidiDriver::HandleNotification(const MIDINotification *message)
  217. {
  218. // Empty
  219. }
  220. int
  221. JackCoreMidiDriver::Open(bool capturing, bool playing, int in_channels,
  222. int out_channels, bool monitor,
  223. const char* capture_driver_name,
  224. const char* playback_driver_name,
  225. jack_nframes_t capture_latency,
  226. jack_nframes_t playback_latency)
  227. {
  228. int pi_count = 0;
  229. int po_count = 0;
  230. int vi_count = 0;
  231. int vo_count = 0;
  232. ItemCount potential_po_count;
  233. ItemCount potential_pi_count;
  234. CFStringRef name = CFStringCreateWithCString(0, "JackMidi",
  235. CFStringGetSystemEncoding());
  236. if (! name) {
  237. jack_error("JackCoreMidiDriver::Open - failed to allocate memory for "
  238. "client name string");
  239. return -1;
  240. }
  241. OSStatus status = MIDIClientCreate(name, HandleNotificationEvent, this,
  242. &client);
  243. CFRelease(name);
  244. if (status != noErr) {
  245. WriteMacOSError("JackCoreMidiDriver::Close", "MIDIClientCreate",
  246. status);
  247. return -1;
  248. }
  249. char *client_name = fClientControl.fName;
  250. // Allocate and connect physical inputs
  251. potential_pi_count = MIDIGetNumberOfSources();
  252. if (potential_pi_count) {
  253. status = MIDIInputPortCreate(client, CFSTR("Physical Input Port"),
  254. HandleInputEvent, this, &internal_input);
  255. if (status != noErr) {
  256. WriteMacOSError("JackCoreMidiDriver::Open", "MIDIInputPortCreate",
  257. status);
  258. goto destroy_virtual_output_ports;
  259. }
  260. try {
  261. physical_input_ports =
  262. new JackCoreMidiPhysicalInputPort*[potential_pi_count];
  263. } catch (std::exception e) {
  264. jack_error("JackCoreMidiDriver::Open - while creating physical "
  265. "input port array: %s", e.what());
  266. goto destroy_internal_input_port;
  267. }
  268. for (ItemCount i = 0; i < potential_pi_count; i++) {
  269. try {
  270. physical_input_ports[pi_count] =
  271. new JackCoreMidiPhysicalInputPort(fAliasName, client_name,
  272. capture_driver_name, i,
  273. client, internal_input,
  274. time_ratio);
  275. } catch (std::exception e) {
  276. jack_error("JackCoreMidiDriver::Open - while creating "
  277. "physical input port: %s", e.what());
  278. goto destroy_internal_input_port;
  279. }
  280. pi_count++;
  281. }
  282. }
  283. // Allocate and connect physical outputs
  284. potential_po_count = MIDIGetNumberOfDestinations();
  285. if (potential_po_count) {
  286. status = MIDIOutputPortCreate(client, CFSTR("Physical Output Port"),
  287. &internal_output);
  288. if (status != noErr) {
  289. WriteMacOSError("JackCoreMidiDriver::Open", "MIDIOutputPortCreate",
  290. status);
  291. goto destroy_physical_input_ports;
  292. }
  293. try {
  294. physical_output_ports =
  295. new JackCoreMidiPhysicalOutputPort*[potential_po_count];
  296. } catch (std::exception e) {
  297. jack_error("JackCoreMidiDriver::Open - while creating physical "
  298. "output port array: %s", e.what());
  299. goto destroy_internal_output_port;
  300. }
  301. for (ItemCount i = 0; i < potential_po_count; i++) {
  302. try {
  303. physical_output_ports[po_count] =
  304. new JackCoreMidiPhysicalOutputPort(fAliasName, client_name,
  305. playback_driver_name, i,
  306. client, internal_output,
  307. time_ratio);
  308. } catch (std::exception e) {
  309. jack_error("JackCoreMidiDriver::Open - while creating "
  310. "physical output port: %s", e.what());
  311. goto destroy_internal_output_port;
  312. }
  313. po_count++;
  314. }
  315. }
  316. // Allocate and connect virtual inputs
  317. if (in_channels) {
  318. try {
  319. virtual_input_ports =
  320. new JackCoreMidiVirtualInputPort*[in_channels];
  321. } catch (std::exception e) {
  322. jack_error("JackCoreMidiDriver::Open - while creating virtual "
  323. "input port array: %s", e.what());
  324. goto destroy_client;
  325. }
  326. for (vi_count = 0; vi_count < in_channels; vi_count++) {
  327. try {
  328. virtual_input_ports[vi_count] =
  329. new JackCoreMidiVirtualInputPort(fAliasName, client_name,
  330. capture_driver_name,
  331. vi_count + pi_count, client,
  332. time_ratio);
  333. } catch (std::exception e) {
  334. jack_error("JackCoreMidiDriver::Open - while creating virtual "
  335. "input port: %s", e.what());
  336. goto destroy_virtual_input_ports;
  337. }
  338. }
  339. }
  340. // Allocate and connect virtual outputs
  341. if (out_channels) {
  342. try {
  343. virtual_output_ports =
  344. new JackCoreMidiVirtualOutputPort*[out_channels];
  345. } catch (std::exception e) {
  346. jack_error("JackCoreMidiDriver::Open - while creating virtual "
  347. "output port array: %s", e.what());
  348. goto destroy_virtual_input_ports;
  349. }
  350. for (vo_count = 0; vo_count < out_channels; vo_count++) {
  351. try {
  352. virtual_output_ports[vo_count] =
  353. new JackCoreMidiVirtualOutputPort(fAliasName, client_name,
  354. playback_driver_name,
  355. vo_count + po_count, client,
  356. time_ratio);
  357. } catch (std::exception e) {
  358. jack_error("JackCoreMidiDriver::Open - while creating virtual "
  359. "output port: %s", e.what());
  360. goto destroy_virtual_output_ports;
  361. }
  362. }
  363. }
  364. if (! (pi_count || po_count || in_channels || out_channels)) {
  365. jack_error("JackCoreMidiDriver::Open - no CoreMIDI inputs or outputs "
  366. "found, and no virtual ports allocated.");
  367. } else if (! JackMidiDriver::Open(capturing, playing,
  368. in_channels + pi_count,
  369. out_channels + po_count, monitor,
  370. capture_driver_name,
  371. playback_driver_name, capture_latency,
  372. playback_latency)) {
  373. num_physical_inputs = pi_count;
  374. num_physical_outputs = po_count;
  375. num_virtual_inputs = in_channels;
  376. num_virtual_outputs = out_channels;
  377. return 0;
  378. }
  379. // Cleanup
  380. if (physical_output_ports) {
  381. for (int i = 0; i < po_count; i++) {
  382. delete physical_output_ports[i];
  383. }
  384. delete[] physical_output_ports;
  385. physical_output_ports = 0;
  386. }
  387. destroy_internal_output_port:
  388. status = MIDIPortDispose(internal_output);
  389. if (status != noErr) {
  390. WriteMacOSError("JackCoreMidiDriver::Open", "MIDIPortDispose", status);
  391. }
  392. destroy_physical_input_ports:
  393. if (physical_input_ports) {
  394. for (int i = 0; i < pi_count; i++) {
  395. delete physical_input_ports[i];
  396. }
  397. delete[] physical_input_ports;
  398. physical_input_ports = 0;
  399. }
  400. destroy_internal_input_port:
  401. status = MIDIPortDispose(internal_input);
  402. if (status != noErr) {
  403. WriteMacOSError("JackCoreMidiDriver::Open", "MIDIPortDispose", status);
  404. }
  405. destroy_virtual_output_ports:
  406. if (virtual_output_ports) {
  407. for (int i = 0; i < vo_count; i++) {
  408. delete virtual_output_ports[i];
  409. }
  410. delete[] virtual_output_ports;
  411. virtual_output_ports = 0;
  412. }
  413. destroy_virtual_input_ports:
  414. if (virtual_input_ports) {
  415. for (int i = 0; i < vi_count; i++) {
  416. delete virtual_input_ports[i];
  417. }
  418. delete[] virtual_input_ports;
  419. virtual_input_ports = 0;
  420. }
  421. destroy_client:
  422. status = MIDIClientDispose(client);
  423. if (status != noErr) {
  424. WriteMacOSError("JackCoreMidiDriver::Open", "MIDIClientDispose",
  425. status);
  426. }
  427. client = 0;
  428. return -1;
  429. }
  430. int
  431. JackCoreMidiDriver::Read()
  432. {
  433. jack_nframes_t buffer_size = fEngineControl->fBufferSize;
  434. for (int i = 0; i < num_physical_inputs; i++) {
  435. physical_input_ports[i]->ProcessJack(GetInputBuffer(i), buffer_size);
  436. }
  437. for (int i = 0; i < num_virtual_inputs; i++) {
  438. virtual_input_ports[i]->
  439. ProcessJack(GetInputBuffer(num_physical_inputs + i), buffer_size);
  440. }
  441. return 0;
  442. }
  443. int
  444. JackCoreMidiDriver::Start()
  445. {
  446. jack_info("JackCoreMidiDriver::Start - Starting driver.");
  447. JackMidiDriver::Start();
  448. int pi_count = 0;
  449. int po_count = 0;
  450. int vi_count = 0;
  451. int vo_count = 0;
  452. jack_info("JackCoreMidiDriver::Start - Enabling physical input ports.");
  453. for (; pi_count < num_physical_inputs; pi_count++) {
  454. if (physical_input_ports[pi_count]->Start() < 0) {
  455. jack_error("JackCoreMidiDriver::Start - Failed to enable physical "
  456. "input port.");
  457. goto stop_physical_input_ports;
  458. }
  459. }
  460. jack_info("JackCoreMidiDriver::Start - Enabling physical output ports.");
  461. for (; po_count < num_physical_outputs; po_count++) {
  462. if (physical_output_ports[po_count]->Start() < 0) {
  463. jack_error("JackCoreMidiDriver::Start - Failed to enable physical "
  464. "output port.");
  465. goto stop_physical_output_ports;
  466. }
  467. }
  468. jack_info("JackCoreMidiDriver::Start - Enabling virtual input ports.");
  469. for (; vi_count < num_virtual_inputs; vi_count++) {
  470. if (virtual_input_ports[vi_count]->Start() < 0) {
  471. jack_error("JackCoreMidiDriver::Start - Failed to enable virtual "
  472. "input port.");
  473. goto stop_virtual_input_ports;
  474. }
  475. }
  476. jack_info("JackCoreMidiDriver::Start - Enabling virtual output ports.");
  477. for (; vo_count < num_virtual_outputs; vo_count++) {
  478. if (virtual_output_ports[vo_count]->Start() < 0) {
  479. jack_error("JackCoreMidiDriver::Start - Failed to enable virtual "
  480. "output port.");
  481. goto stop_virtual_output_ports;
  482. }
  483. }
  484. jack_info("JackCoreMidiDriver::Start - Driver started.");
  485. return 0;
  486. stop_virtual_output_ports:
  487. for (int i = 0; i < vo_count; i++) {
  488. if (virtual_output_ports[i]->Stop() < 0) {
  489. jack_error("JackCoreMidiDriver::Start - Failed to disable virtual "
  490. "output port.");
  491. }
  492. }
  493. stop_virtual_input_ports:
  494. for (int i = 0; i < vi_count; i++) {
  495. if (virtual_input_ports[i]->Stop() < 0) {
  496. jack_error("JackCoreMidiDriver::Start - Failed to disable virtual "
  497. "input port.");
  498. }
  499. }
  500. stop_physical_output_ports:
  501. for (int i = 0; i < po_count; i++) {
  502. if (physical_output_ports[i]->Stop() < 0) {
  503. jack_error("JackCoreMidiDriver::Start - Failed to disable "
  504. "physical output port.");
  505. }
  506. }
  507. stop_physical_input_ports:
  508. for (int i = 0; i < pi_count; i++) {
  509. if (physical_input_ports[i]->Stop() < 0) {
  510. jack_error("JackCoreMidiDriver::Start - Failed to disable "
  511. "physical input port.");
  512. }
  513. }
  514. return -1;
  515. }
  516. int
  517. JackCoreMidiDriver::Stop()
  518. {
  519. int result = 0;
  520. jack_info("JackCoreMidiDriver::Stop - disabling physical input ports.");
  521. for (int i = 0; i < num_physical_inputs; i++) {
  522. if (physical_input_ports[i]->Stop() < 0) {
  523. jack_error("JackCoreMidiDriver::Stop - Failed to disable physical "
  524. "input port.");
  525. result = -1;
  526. }
  527. }
  528. jack_info("JackCoreMidiDriver::Stop - disabling physical output ports.");
  529. for (int i = 0; i < num_physical_outputs; i++) {
  530. if (physical_output_ports[i]->Stop() < 0) {
  531. jack_error("JackCoreMidiDriver::Stop - Failed to disable physical "
  532. "output port.");
  533. result = -1;
  534. }
  535. }
  536. jack_info("JackCoreMidiDriver::Stop - disabling virtual input ports.");
  537. for (int i = 0; i < num_virtual_inputs; i++) {
  538. if (virtual_input_ports[i]->Stop() < 0) {
  539. jack_error("JackCoreMidiDriver::Stop - Failed to disable virtual "
  540. "input port.");
  541. result = -1;
  542. }
  543. }
  544. jack_info("JackCoreMidiDriver::Stop - disabling virtual output ports.");
  545. for (int i = 0; i < num_virtual_outputs; i++) {
  546. if (virtual_output_ports[i]->Stop() < 0) {
  547. jack_error("JackCoreMidiDriver::Stop - Failed to disable virtual "
  548. "output port.");
  549. result = -1;
  550. }
  551. }
  552. return result;
  553. }
  554. int
  555. JackCoreMidiDriver::Write()
  556. {
  557. jack_nframes_t buffer_size = fEngineControl->fBufferSize;
  558. for (int i = 0; i < num_physical_outputs; i++) {
  559. physical_output_ports[i]->ProcessJack(GetOutputBuffer(i), buffer_size);
  560. }
  561. for (int i = 0; i < num_virtual_outputs; i++) {
  562. virtual_output_ports[i]->
  563. ProcessJack(GetOutputBuffer(num_physical_outputs + i),
  564. buffer_size);
  565. }
  566. return 0;
  567. }
  568. #ifdef __cplusplus
  569. extern "C" {
  570. #endif
  571. SERVER_EXPORT jack_driver_desc_t * driver_get_descriptor()
  572. {
  573. jack_driver_desc_t * desc;
  574. jack_driver_desc_filler_t filler;
  575. jack_driver_param_value_t value;
  576. desc = jack_driver_descriptor_construct("coremidi", JackDriverSlave, "Apple CoreMIDI API based MIDI backend", &filler);
  577. value.ui = 0;
  578. jack_driver_descriptor_add_parameter(desc, &filler, "inchannels", 'i', JackDriverParamUInt, &value, NULL, "CoreMIDI virtual bus", NULL);
  579. jack_driver_descriptor_add_parameter(desc, &filler, "outchannels", 'o', JackDriverParamUInt, &value, NULL, "CoreMIDI virtual bus", NULL);
  580. return desc;
  581. }
  582. SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params)
  583. {
  584. const JSList * node;
  585. const jack_driver_param_t * param;
  586. int virtual_in = 0;
  587. int virtual_out = 0;
  588. for (node = params; node; node = jack_slist_next (node)) {
  589. param = (const jack_driver_param_t *) node->data;
  590. switch (param->character) {
  591. case 'i':
  592. virtual_in = param->value.ui;
  593. break;
  594. case 'o':
  595. virtual_out = param->value.ui;
  596. break;
  597. }
  598. }
  599. Jack::JackDriverClientInterface* driver = new Jack::JackCoreMidiDriver("system_midi", "coremidi", engine, table);
  600. if (driver->Open(1, 1, virtual_in, virtual_out, false, "in", "out", 0, 0) == 0) {
  601. return driver;
  602. } else {
  603. delete driver;
  604. return NULL;
  605. }
  606. }
  607. #ifdef __cplusplus
  608. }
  609. #endif