Commit 83baac75 authored by Stephane Letz's avatar Stephane Letz
Browse files

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

parent 2731c1e8
......@@ -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
......
......@@ -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:
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 kMIDIMsgObjectAdded:
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;
......
......@@ -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;
......
......@@ -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,
......@@ -47,6 +45,11 @@ namespace Jack {
double time_ratio;
MIDIEndpointRef endpoint;
MIDIEndpointRef
GetEndpoint();
static std::set<MIDIEndpointRef> endpoint_list;
public:
JackCoreMidiPort(double time_ratio);
......@@ -60,6 +63,8 @@ namespace Jack {
const char *
GetName();
static bool IsInternalPort(MIDIObjectRef port_aux);
};
}
......
......@@ -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()
......
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment