00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <sstream>
00021 #include <stdexcept>
00022
00023 #include "JackCoreMidiPhysicalOutputPort.h"
00024 #include "JackCoreMidiUtil.h"
00025
00026 using Jack::JackCoreMidiPhysicalOutputPort;
00027
00028 JackCoreMidiPhysicalOutputPort::
00029 JackCoreMidiPhysicalOutputPort(const char *alias_name, const char *client_name,
00030 const char *driver_name, int index,
00031 MIDIClientRef client,
00032 MIDIPortRef internal_output, double time_ratio,
00033 size_t max_bytes,
00034 size_t max_messages):
00035 JackCoreMidiOutputPort(time_ratio, max_bytes,
00036 max_messages)
00037 {
00038 MIDIEndpointRef destination = MIDIGetDestination(index);
00039 if (! destination) {
00040
00041 std::stringstream stream;
00042 stream << "The destination at index '" << index
00043 << "' is not available";
00044 throw std::runtime_error(stream.str().c_str());
00045 }
00046 SInt32 advance_schedule_time;
00047 OSStatus status =
00048 MIDIObjectGetIntegerProperty(destination,
00049 kMIDIPropertyAdvanceScheduleTimeMuSec,
00050 &advance_schedule_time);
00051 if (status != noErr) {
00052 WriteMacOSError("JackCoreMidiPhysicalOutputPort [constructor]",
00053 "MIDIObjectGetIntegerProperty", status);
00054 advance_schedule_time = 0;
00055 } else if (advance_schedule_time < 0) {
00056 advance_schedule_time = 0;
00057 }
00058 Initialize(alias_name, client_name, driver_name, index, destination,
00059 advance_schedule_time);
00060 this->internal_output = internal_output;
00061 }
00062
00063 JackCoreMidiPhysicalOutputPort::~JackCoreMidiPhysicalOutputPort()
00064 {
00065
00066 }
00067
00068 bool
00069 JackCoreMidiPhysicalOutputPort::SendPacketList(MIDIPacketList *packet_list)
00070 {
00071 OSStatus status = MIDISend(internal_output, endpoint, packet_list);
00072 bool result = status == noErr;
00073 if (! result) {
00074 WriteMacOSError("JackCoreMidiPhysicalOutputPort::SendPacketList",
00075 "MIDISend", status);
00076 }
00077 return result;
00078 }