int midiCleanUp()
{
	/*
	* do not catch errors when disposing ports
	* MIDIClientDispose should normally dispose the ports attached to it
	* but clean up the pointers in case
	*/
	int i = 0;
	for (i=0; i<gNumMIDIOutPorts; ++i) {
		MIDIPortDispose(gMIDIOutPort[i]);
		gMIDIOutPort[i] = 0;
	}
	gNumMIDIOutPorts = 0;

	for (i=0; i<gNumMIDIInPorts; ++i) {
		MIDIPortDispose(gMIDIInPort[i]);
		gMIDIInPort[i] = 0;
	}
	gNumMIDIInPorts = 0;

	if (gMIDIClient) {
		if( MIDIClientDispose(gMIDIClient) ) {
			post( "Error: failed to dispose MIDIClient\n" );
			return errFailed;
		}
		gMIDIClient = 0;
	}
	return errNone;
}
bool CoreMidiInputDevice::open()
{
    qDebug() << Q_FUNC_INFO;

    // Don't open twice
    if (m_inPort != 0)
        return false;

    OSStatus s = MIDIInputPortCreate(m_client, CFSTR("QLC Input Port"),
                                     MidiInProc, this, &m_inPort);
    if (s != 0)
    {
        qWarning() << Q_FUNC_INFO << "Unable to make an input port for"
                   << name() << ":" << s;
        m_inPort = 0;
    }
    else
    {
        // Connect the input port to the first source
        m_source = MIDIEntityGetSource(m_entity, 0);
        s = MIDIPortConnectSource(m_inPort, m_source, this);
        if (s != 0)
        {
            qWarning() << Q_FUNC_INFO << "Unable to connect input port to source for"
                       << name() << ":" << s;

            s = MIDIPortDispose(m_inPort);
            if (s != 0)
                qWarning() << "Unable to dispose of input port in" << name();
            m_inPort = 0;
        }
    }
    return true;
}
        ~MidiPortAndEndpoint() noexcept
        {
            if (port != 0)
                MIDIPortDispose (port);

            if (port == 0 && endPoint != 0) // if port == nullptr, it means we created the endpoint, so it's safe to delete it
                MIDIEndpointDispose (endPoint);
        }
Beispiel #4
0
void MidiDriver_CoreMIDI::close() {
	MidiDriver_MPU401::close();

	if (mOutPort && mDest) {
		MIDIPortDispose(mOutPort);
		mOutPort = 0;
		mDest = 0;
	}
}
void CoreMidiDriver::close()
{
	OSStatus err = noErr;
	err = MIDIPortDisconnectSource( h2InputRef, cmH2Src );
	err = MIDIPortDispose( h2InputRef );
	//err = MIDIPortDisconnectSource( h2OutputRef, cmH2Dst );
	//err = MIDIPortDispose( h2OutputRef );
	err = MIDIClientDispose( h2MIDIClient );
}
void CoreMidiOutputDevice::close()
{
    qDebug() << Q_FUNC_INFO;

    // Don't close twice
    if (m_outPort == 0)
        return;

    OSStatus s = MIDIPortDispose(m_outPort);
    if (s != 0)
        qWarning() << "Unable to dispose of output port in" << name();
    m_outPort = 0;
}
void CoreMidiInputDevice::close()
{
    qDebug() << Q_FUNC_INFO;

    // Don't close twice
    if (m_inPort == 0)
        return;

    OSStatus s = MIDIPortDisconnectSource(m_inPort, 0);
    if (s != 0)
        qWarning() << Q_FUNC_INFO << "Unable to disconnect input source in" << name();

    s = MIDIPortDispose(m_inPort);
    if (s != 0)
        qWarning() << "Unable to dispose of input port in" << name();
    m_inPort = 0;
}
Beispiel #8
0
void MIDIDevice::close()
{
    OSStatus s;

    if (m_outPort != 0 && m_destination != 0)
    {
        s = MIDIPortDispose(m_outPort);
        if (s != 0)
        {
            qWarning() << "Unable to dispose of output port for" << name();
        }
        else
        {
            m_outPort = 0;
            m_destination = 0;
        }
    }
}
Beispiel #9
0
void MIDIDriverCoreMidi::close() {

	for (int i = 0; i < connected_sources.size(); i++) {
		MIDIEndpointRef source = connected_sources[i];
		MIDIPortDisconnectSource(port_in, source);
	}
	connected_sources.clear();

	if (port_in != 0) {
		MIDIPortDispose(port_in);
		port_in = 0;
	}

	if (client != 0) {
		MIDIClientDispose(client);
		client = 0;
	}
}
Beispiel #10
0
// ----------------------------------------------------------
ofxAudioUnitMidiReceiver::~ofxAudioUnitMidiReceiver()
// ----------------------------------------------------------
{
	MIDIPortDispose(_port);
	MIDIEndpointDispose(_endpoint);
}
Beispiel #11
0
MIDIClient::~MIDIClient() {
    MIDIClientDispose(client);
    MIDIPortDispose(inPort);
    MIDIPortDispose(outPort);
}
Beispiel #12
0
MidiIn::~MidiIn()
{
    if (!handle) return;
    MIDIPortDispose((MIDIPortRef) handle);
}
JNIEXPORT jint JNICALL Java_com_apple_audio_CAObjectManagement_MIDIPortDispose
  (JNIEnv *, jclass, jint port)
{
	return (jint)MIDIPortDispose((MIDIPortRef)port);
}
Beispiel #14
0
/**
 * @brief Destroy a MIDIDriverCoreMIDI instance.
 * Free all resources occupied by the driver.
 * @public @memberof MIDIDriverCoreMIDI
 * @param driver The driver.
 */
void MIDIDriverCoreMIDIDestroy( struct MIDIDriverCoreMIDI * driver ) {
  MIDIPortDispose( driver->cm_in_port );
  MIDIPortDispose( driver->cm_out_port );
}