Browse Source

Add support for advance scheduling via driver preferences. Hope this doesn't break anything.

tags/1.9.8
Devin Anderson 14 years ago
parent
commit
66200176dc
4 changed files with 29 additions and 16 deletions
  1. +12
    -13
      macosx/coremidi/JackCoreMidiOutputPort.cpp
  2. +2
    -1
      macosx/coremidi/JackCoreMidiOutputPort.h
  3. +14
    -1
      macosx/coremidi/JackCoreMidiPhysicalOutputPort.cpp
  4. +1
    -1
      macosx/coremidi/JackCoreMidiVirtualOutputPort.cpp

+ 12
- 13
macosx/coremidi/JackCoreMidiOutputPort.cpp View File

@@ -44,6 +44,7 @@ JackCoreMidiOutputPort::JackCoreMidiOutputPort(double time_ratio,
if (thread_queue_semaphore == (sem_t *) SEM_FAILED) {
throw std::runtime_error(strerror(errno));
}
advance_schedule_time = 0;
thread_ptr.release();
thread_queue_ptr.release();
read_queue_ptr.release();
@@ -71,20 +72,15 @@ JackCoreMidiOutputPort::Execute()
event = GetCoreMidiEvent(true);
}
jack_midi_data_t *data = event->buffer;

// This is the latest time that the packet list can be sent out. We
// may want to consider subtracting some frames to leave room for the
// CoreMIDI driver/client to handle all of the events. There's a
// property called 'kMIDIPropertyAdvanceScheduleTimeMuSec' that might
// be useful in this case.
jack_nframes_t send_time = event->time;

jack_nframes_t send_frame = event->time;
jack_time_t send_time =
GetTimeFromFrames(send_frame) - advance_schedule_time;
size_t size = event->size;
MIDITimeStamp timestamp = GetTimeStampFromFrames(send_time);
MIDITimeStamp timestamp = GetTimeStampFromFrames(send_frame);
packet = MIDIPacketListAdd(packet_list, PACKET_BUFFER_SIZE, packet,
timestamp, size, data);
if (packet) {
while (GetCurrentFrame() < send_time) {
while (GetMicroSeconds() < send_time) {
event = GetCoreMidiEvent(false);
if (! event) {
break;
@@ -186,12 +182,15 @@ JackCoreMidiOutputPort::Init()

void
JackCoreMidiOutputPort::Initialize(const char *alias_name,
const char *client_name,
const char *driver_name, int index,
MIDIEndpointRef endpoint)
const char *client_name,
const char *driver_name, int index,
MIDIEndpointRef endpoint,
SInt32 advance_schedule_time)
{
JackCoreMidiPort::Initialize(alias_name, client_name, driver_name, index,
endpoint, true);
assert(advance_schedule_time >= 0);
this->advance_schedule_time = advance_schedule_time;
}

void


+ 2
- 1
macosx/coremidi/JackCoreMidiOutputPort.h View File

@@ -42,6 +42,7 @@ namespace Jack {

static const size_t PACKET_BUFFER_SIZE = 65536;

SInt32 advance_schedule_time;
char packet_buffer[PACKET_BUFFER_SIZE];
JackMidiBufferReadQueue *read_queue;
char semaphore_name[128];
@@ -57,7 +58,7 @@ namespace Jack {
void
Initialize(const char *alias_name, const char *client_name,
const char *driver_name, int index,
MIDIEndpointRef endpoint);
MIDIEndpointRef endpoint, SInt32 advance_schedule_time);

public:



+ 14
- 1
macosx/coremidi/JackCoreMidiPhysicalOutputPort.cpp View File

@@ -43,7 +43,20 @@ JackCoreMidiPhysicalOutputPort(const char *alias_name, const char *client_name,
<< "' is not available";
throw std::runtime_error(stream.str().c_str());
}
Initialize(alias_name, client_name, driver_name, index, destination);
SInt32 advance_schedule_time;
OSStatus status =
MIDIObjectGetIntegerProperty(destination,
kMIDIPropertyAdvanceScheduleTimeMuSec,
&advance_schedule_time);
if (status != noErr) {
WriteMacOSError("JackCoreMidiPhysicalOutputPort [constructor]",
"MIDIObjectGetIntegerProperty", status);
advance_schedule_time = 0;
} else if (advance_schedule_time < 0) {
advance_schedule_time = 0;
}
Initialize(alias_name, client_name, driver_name, index, destination,
advance_schedule_time);
this->internal_output = internal_output;
}



+ 1
- 1
macosx/coremidi/JackCoreMidiVirtualOutputPort.cpp View File

@@ -47,7 +47,7 @@ JackCoreMidiVirtualOutputPort(const char *alias_name, const char *client_name,
if (status != noErr) {
throw std::runtime_error(GetMacOSErrorString(status));
}
Initialize(alias_name, client_name, driver_name, index, source);
Initialize(alias_name, client_name, driver_name, index, source, 0);
}

JackCoreMidiVirtualOutputPort::~JackCoreMidiVirtualOutputPort()


Loading…
Cancel
Save