Browse Source

Open one virtual in/out in CoreMidi driver, fix a state refresh issue.

tags/v1.9.10
Stephane Letz 12 years ago
parent
commit
83baac750d
7 changed files with 47 additions and 18 deletions
  1. +1
    -1
      common/jack/jack.h
  2. +21
    -13
      macosx/coremidi/JackCoreMidiDriver.cpp
  3. +1
    -1
      macosx/coremidi/JackCoreMidiDriver.h
  4. +8
    -0
      macosx/coremidi/JackCoreMidiPort.cpp
  5. +8
    -3
      macosx/coremidi/JackCoreMidiPort.h
  6. +4
    -0
      macosx/coremidi/JackCoreMidiVirtualInputPort.cpp
  7. +4
    -0
      macosx/coremidi/JackCoreMidiVirtualOutputPort.cpp

+ 1
- 1
common/jack/jack.h View File

@@ -1010,7 +1010,7 @@ size_t jack_port_type_get_buffer_size (jack_client_t *client, const char *port_t
* latency values associated with them, both measured in frames:
*
* <b>capture latency</b>: how long since the data read from
* the buffer of a port arrived at at
* the buffer of a port arrived at
* a port marked with JackPortIsTerminal.
* The data will have come from the "outside
* world" if the terminal port is also


+ 21
- 13
macosx/coremidi/JackCoreMidiDriver.cpp View File

@@ -112,7 +112,6 @@ bool JackCoreMidiDriver::OpenAux()

OSStatus status = MIDIClientCreate(name, HandleNotificationEvent, this,
&client);

CFRelease(name);

if (status != noErr) {
@@ -246,7 +245,6 @@ bool JackCoreMidiDriver::OpenAux()
}
}


if (! (pi_count || po_count || in_channels || out_channels)) {
jack_error("JackCoreMidiDriver::Open - no CoreMIDI inputs or outputs "
"found, and no virtual ports allocated.");
@@ -522,7 +520,6 @@ void
JackCoreMidiDriver::Restart()
{
JackLock lock(this);

SaveConnections();
Stop();
Detach();
@@ -538,16 +535,27 @@ JackCoreMidiDriver::HandleNotification(const MIDINotification *message)
{
switch (message->messageID) {

case kMIDIMsgSetupChanged:
Restart();
break;

case kMIDIMsgObjectAdded:
case kMIDIMsgObjectAdded: {
/*
We don't want to restart when our internal virtual in/out are created.
*/
const MIDIObjectAddRemoveNotification* add_message = reinterpret_cast<const MIDIObjectAddRemoveNotification*>(message);
if (!JackCoreMidiPort::IsInternalPort(add_message->child)) {
Restart();
}
break;

case kMIDIMsgObjectRemoved:
}
case kMIDIMsgObjectRemoved: {
/*
We don't want to restart when our internal virtual in/out are created.
*/
const MIDIObjectAddRemoveNotification* remove_message = reinterpret_cast<const MIDIObjectAddRemoveNotification*>(message);
if (!JackCoreMidiPort::IsInternalPort(remove_message->child)) {
Restart();
}
break;

}
}
}

@@ -809,8 +817,8 @@ extern "C" {
{
const JSList * node;
const jack_driver_param_t * param;
int virtual_in = 0;
int virtual_out = 0;
int virtual_in = 1;
int virtual_out = 1;

for (node = params; node; node = jack_slist_next (node)) {
param = (const jack_driver_param_t *) node->data;


+ 1
- 1
macosx/coremidi/JackCoreMidiDriver.h View File

@@ -61,7 +61,7 @@ namespace Jack {
int CloseAux();

void Restart();
JackThread fThread; /*! Thread to execute the Process function */

public:


+ 8
- 0
macosx/coremidi/JackCoreMidiPort.cpp View File

@@ -25,6 +25,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

using Jack::JackCoreMidiPort;

std::set<MIDIEndpointRef> JackCoreMidiPort::endpoint_list;

bool JackCoreMidiPort::IsInternalPort(MIDIObjectRef port_aux)
{
MIDIEndpointRef port = (MIDIEndpointRef)port_aux;
return std::find(endpoint_list.begin(), endpoint_list.end(), port) != endpoint_list.end();
}

JackCoreMidiPort::JackCoreMidiPort(double time_ratio)
{
initialized = false;


+ 8
- 3
macosx/coremidi/JackCoreMidiPort.h View File

@@ -21,6 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define __JackCoreMidiPort__

#include <CoreMIDI/CoreMIDI.h>
#include <set>

#include "JackConstants.h"

@@ -36,9 +37,6 @@ namespace Jack {

protected:

MIDIEndpointRef
GetEndpoint();

void
Initialize(const char *alias_name, const char *client_name,
const char *driver_name, int index,
@@ -46,6 +44,11 @@ namespace Jack {

double time_ratio;
MIDIEndpointRef endpoint;
MIDIEndpointRef
GetEndpoint();
static std::set<MIDIEndpointRef> endpoint_list;

public:

@@ -59,6 +62,8 @@ namespace Jack {

const char *
GetName();
static bool IsInternalPort(MIDIObjectRef port_aux);

};



+ 4
- 0
macosx/coremidi/JackCoreMidiVirtualInputPort.cpp View File

@@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <sstream>
#include <stdexcept>

#include "JackError.h"
#include "JackCoreMidiUtil.h"
#include "JackCoreMidiVirtualInputPort.h"

@@ -63,6 +64,9 @@ JackCoreMidiVirtualInputPort(const char *alias_name, const char *client_name,
throw std::runtime_error(GetMacOSErrorString(status));
}
Initialize(alias_name, client_name, driver_name, index, destination);
// Keep in global list (that keeps growing during the whole session...)
endpoint_list.insert(endpoint);
}

JackCoreMidiVirtualInputPort::~JackCoreMidiVirtualInputPort()


+ 4
- 0
macosx/coremidi/JackCoreMidiVirtualOutputPort.cpp View File

@@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <sstream>
#include <stdexcept>

#include "JackError.h"
#include "JackCoreMidiUtil.h"
#include "JackCoreMidiVirtualOutputPort.h"

@@ -48,6 +49,9 @@ JackCoreMidiVirtualOutputPort(const char *alias_name, const char *client_name,
throw std::runtime_error(GetMacOSErrorString(status));
}
Initialize(alias_name, client_name, driver_name, index, source, 0);
// Keep in global list (that keeps growing during the whole session...)
endpoint_list.insert(GetEndpoint());
}

JackCoreMidiVirtualOutputPort::~JackCoreMidiVirtualOutputPort()


Loading…
Cancel
Save