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.

79 lines
2.8KB

  1. /*
  2. Copyright (C) 2011 Devin Anderson
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #include <sstream>
  16. #include <stdexcept>
  17. #include "JackCoreMidiPhysicalOutputPort.h"
  18. #include "JackCoreMidiUtil.h"
  19. using Jack::JackCoreMidiPhysicalOutputPort;
  20. JackCoreMidiPhysicalOutputPort::
  21. JackCoreMidiPhysicalOutputPort(const char *alias_name, const char *client_name,
  22. const char *driver_name, int index,
  23. MIDIClientRef client,
  24. MIDIPortRef internal_output, double time_ratio,
  25. size_t max_bytes,
  26. size_t max_messages):
  27. JackCoreMidiOutputPort(time_ratio, max_bytes,
  28. max_messages)
  29. {
  30. MIDIEndpointRef destination = MIDIGetDestination(index);
  31. if (! destination) {
  32. // X: Can we get a better error message?
  33. std::stringstream stream;
  34. stream << "The destination at index '" << index
  35. << "' is not available";
  36. throw std::runtime_error(stream.str().c_str());
  37. }
  38. SInt32 advance_schedule_time;
  39. OSStatus status =
  40. MIDIObjectGetIntegerProperty(destination,
  41. kMIDIPropertyAdvanceScheduleTimeMuSec,
  42. &advance_schedule_time);
  43. if (status != noErr) {
  44. WriteMacOSError("JackCoreMidiPhysicalOutputPort [constructor]",
  45. "MIDIObjectGetIntegerProperty", status);
  46. advance_schedule_time = 0;
  47. } else if (advance_schedule_time < 0) {
  48. advance_schedule_time = 0;
  49. }
  50. Initialize(alias_name, client_name, driver_name, index, destination,
  51. advance_schedule_time);
  52. this->internal_output = internal_output;
  53. }
  54. JackCoreMidiPhysicalOutputPort::~JackCoreMidiPhysicalOutputPort()
  55. {
  56. // Empty
  57. }
  58. bool
  59. JackCoreMidiPhysicalOutputPort::SendPacketList(MIDIPacketList *packet_list)
  60. {
  61. OSStatus status = MIDISend(internal_output, endpoint, packet_list);
  62. bool result = status == noErr;
  63. if (! result) {
  64. WriteMacOSError("JackCoreMidiPhysicalOutputPort::SendPacketList",
  65. "MIDISend", status);
  66. }
  67. return result;
  68. }