| @@ -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: | * latency values associated with them, both measured in frames: | ||||
| * | * | ||||
| * <b>capture latency</b>: how long since the data read from | * <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. | * a port marked with JackPortIsTerminal. | ||||
| * The data will have come from the "outside | * The data will have come from the "outside | ||||
| * world" if the terminal port is also | * world" if the terminal port is also | ||||
| @@ -112,7 +112,6 @@ bool JackCoreMidiDriver::OpenAux() | |||||
| OSStatus status = MIDIClientCreate(name, HandleNotificationEvent, this, | OSStatus status = MIDIClientCreate(name, HandleNotificationEvent, this, | ||||
| &client); | &client); | ||||
| CFRelease(name); | CFRelease(name); | ||||
| if (status != noErr) { | if (status != noErr) { | ||||
| @@ -246,7 +245,6 @@ bool JackCoreMidiDriver::OpenAux() | |||||
| } | } | ||||
| } | } | ||||
| if (! (pi_count || po_count || in_channels || out_channels)) { | if (! (pi_count || po_count || in_channels || out_channels)) { | ||||
| jack_error("JackCoreMidiDriver::Open - no CoreMIDI inputs or outputs " | jack_error("JackCoreMidiDriver::Open - no CoreMIDI inputs or outputs " | ||||
| "found, and no virtual ports allocated."); | "found, and no virtual ports allocated."); | ||||
| @@ -522,7 +520,6 @@ void | |||||
| JackCoreMidiDriver::Restart() | JackCoreMidiDriver::Restart() | ||||
| { | { | ||||
| JackLock lock(this); | JackLock lock(this); | ||||
| SaveConnections(); | SaveConnections(); | ||||
| Stop(); | Stop(); | ||||
| Detach(); | Detach(); | ||||
| @@ -538,16 +535,27 @@ JackCoreMidiDriver::HandleNotification(const MIDINotification *message) | |||||
| { | { | ||||
| switch (message->messageID) { | 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; | 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; | break; | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -809,8 +817,8 @@ extern "C" { | |||||
| { | { | ||||
| const JSList * node; | const JSList * node; | ||||
| const jack_driver_param_t * param; | 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)) { | for (node = params; node; node = jack_slist_next (node)) { | ||||
| param = (const jack_driver_param_t *) node->data; | param = (const jack_driver_param_t *) node->data; | ||||
| @@ -61,7 +61,7 @@ namespace Jack { | |||||
| int CloseAux(); | int CloseAux(); | ||||
| void Restart(); | void Restart(); | ||||
| JackThread fThread; /*! Thread to execute the Process function */ | JackThread fThread; /*! Thread to execute the Process function */ | ||||
| public: | public: | ||||
| @@ -25,6 +25,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| using Jack::JackCoreMidiPort; | 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) | JackCoreMidiPort::JackCoreMidiPort(double time_ratio) | ||||
| { | { | ||||
| initialized = false; | initialized = false; | ||||
| @@ -21,6 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| #define __JackCoreMidiPort__ | #define __JackCoreMidiPort__ | ||||
| #include <CoreMIDI/CoreMIDI.h> | #include <CoreMIDI/CoreMIDI.h> | ||||
| #include <set> | |||||
| #include "JackConstants.h" | #include "JackConstants.h" | ||||
| @@ -36,9 +37,6 @@ namespace Jack { | |||||
| protected: | protected: | ||||
| MIDIEndpointRef | |||||
| GetEndpoint(); | |||||
| void | void | ||||
| Initialize(const char *alias_name, const char *client_name, | Initialize(const char *alias_name, const char *client_name, | ||||
| const char *driver_name, int index, | const char *driver_name, int index, | ||||
| @@ -46,6 +44,11 @@ namespace Jack { | |||||
| double time_ratio; | double time_ratio; | ||||
| MIDIEndpointRef endpoint; | MIDIEndpointRef endpoint; | ||||
| MIDIEndpointRef | |||||
| GetEndpoint(); | |||||
| static std::set<MIDIEndpointRef> endpoint_list; | |||||
| public: | public: | ||||
| @@ -59,6 +62,8 @@ namespace Jack { | |||||
| const char * | const char * | ||||
| GetName(); | GetName(); | ||||
| static bool IsInternalPort(MIDIObjectRef port_aux); | |||||
| }; | }; | ||||
| @@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| #include <sstream> | #include <sstream> | ||||
| #include <stdexcept> | #include <stdexcept> | ||||
| #include "JackError.h" | |||||
| #include "JackCoreMidiUtil.h" | #include "JackCoreMidiUtil.h" | ||||
| #include "JackCoreMidiVirtualInputPort.h" | #include "JackCoreMidiVirtualInputPort.h" | ||||
| @@ -63,6 +64,9 @@ JackCoreMidiVirtualInputPort(const char *alias_name, const char *client_name, | |||||
| throw std::runtime_error(GetMacOSErrorString(status)); | throw std::runtime_error(GetMacOSErrorString(status)); | ||||
| } | } | ||||
| Initialize(alias_name, client_name, driver_name, index, destination); | 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() | JackCoreMidiVirtualInputPort::~JackCoreMidiVirtualInputPort() | ||||
| @@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| #include <sstream> | #include <sstream> | ||||
| #include <stdexcept> | #include <stdexcept> | ||||
| #include "JackError.h" | |||||
| #include "JackCoreMidiUtil.h" | #include "JackCoreMidiUtil.h" | ||||
| #include "JackCoreMidiVirtualOutputPort.h" | #include "JackCoreMidiVirtualOutputPort.h" | ||||
| @@ -48,6 +49,9 @@ JackCoreMidiVirtualOutputPort(const char *alias_name, const char *client_name, | |||||
| throw std::runtime_error(GetMacOSErrorString(status)); | throw std::runtime_error(GetMacOSErrorString(status)); | ||||
| } | } | ||||
| Initialize(alias_name, client_name, driver_name, index, source, 0); | 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() | JackCoreMidiVirtualOutputPort::~JackCoreMidiVirtualOutputPort() | ||||