void CoreMidiDriver::close() { OSStatus err = noErr; err = MIDIPortDisconnectSource( h2InputRef, cmH2Src ); err = MIDIPortDispose( h2InputRef ); //err = MIDIPortDisconnectSource( h2OutputRef, cmH2Dst ); //err = MIDIPortDispose( h2OutputRef ); err = MIDIClientDispose( h2MIDIClient ); }
static int _macosx_stop(struct midi_port *p) { struct macosx_midi *m; m = (struct macosx_midi *)p->userdata; if (p->io & MIDI_INPUT && MIDIPortDisconnectSource(portIn, m->ep) != noErr) { return 0; } return 1; }
// source is identified by the index in the array returned by get_sources // input_port is an InputPort class static VALUE t_disconnect_source_from_port(VALUE self, VALUE source_idx, VALUE input_port) { RbInputPort* port; Data_Get_Struct(input_port, RbInputPort, port); MIDIEndpointRef source = MIDIGetSource(FIX2INT(source_idx)); MIDIPortDisconnectSource(port->input_port, source); return Qtrue; }
~MidiPortAndCallback() { active = false; { const ScopedLock sl (callbackLock); activeCallbacks.removeFirstMatchingValue (this); } if (portAndEndpoint != 0 && portAndEndpoint->port != 0) CHECK_ERROR (MIDIPortDisconnectSource (portAndEndpoint->port, portAndEndpoint->endPoint)); }
//_________________________________________________________ void RemoveSlotList (SlotPtr slot, Boolean input) { OSStatus err; SlotPtr next; while (slot) { next = slot->next; if (input) err = MIDIPortDisconnectSource(gInPort, slot->src); // disconnect source MidiRemoveSlot(slot->refNum); FreeSlot (slot); slot = next; } }
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; }
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; } }
int prDisconnectMIDIIn(struct VMGlobals *g, int numArgsPushed) { PyrSlot *b = g->sp - 1; PyrSlot *c = g->sp; int err, inputIndex, uid; err = slotIntVal(b, &inputIndex); if (err) return err; if (inputIndex < 0 || inputIndex >= gNumMIDIInPorts) return errIndexOutOfRange; err = slotIntVal(c, &uid); if (err) return err; MIDIEndpointRef src=0; MIDIObjectType mtype; MIDIObjectFindByUniqueID(uid, (MIDIObjectRef*)&src, &mtype); if (mtype != kMIDIObjectType_Source) return errFailed; MIDIPortDisconnectSource(gMIDIInPort[inputIndex], src); return errNone; }
INT32 MIDI_Utils_StopDevice(MacMidiDeviceHandle* handle) { OSStatus err = noErr; if (!handle || !handle->h.deviceHandle) { ERROR0("ERROR: MIDI_Utils_StopDevice: handle or native handle is NULL\n"); return MIDI_INVALID_HANDLE; } if (handle->isStarted) { /* set the flag that we don't want to receive messages anymore */ handle->isStarted = FALSE; if (handle->direction == MIDI_IN) { err = MIDIPortDisconnectSource(inPort, (MIDIEndpointRef) (intptr_t) (handle->h.deviceHandle)); } else if (handle->direction == MIDI_OUT) { // Unschedules previously-sent packets. err = MIDIFlushOutput((MIDIEndpointRef) (intptr_t) handle->h.deviceHandle); } MIDI_CHECK_ERROR; } return MIDI_SUCCESS; }
void MidiApple::midiInClose( MIDIEndpointRef reference ) { qDebug("midiInClose '%s'", getFullName(reference)); MIDIPortRef portRef = m_sourcePortRef[reference]; MIDIPortDisconnectSource(portRef, reference); }
int main(int argc, char *argv[]) { OSStatus err = noErr; // Set up signaling stuff first signal(SIGHUP, &quit); signal(SIGINT, &quit); signal(SIGILL, &quit); signal(SIGTRAP, &quit); signal(SIGABRT, &quit); signal(SIGEMT, &quit); signal(SIGFPE, &quit); signal(SIGBUS, &quit); signal(SIGSEGV, &quit); signal(SIGPIPE, &quit); signal(SIGALRM, &quit); signal(SIGTERM, &quit); signal(SIGURG, &quit); char path[MAX_PATH], tmp[MAX_PATH]; if(getPluginBundleDir(DEF_BUNDLE_STRING, tmp)) { snprintf(path, MAX_PATH, "%s%c%s%c%s%s", tmp, DEF_DELIMITER, DEF_RESOURCE_PATH, DEF_DELIMITER, DEF_PRODUCT, DEF_EXTENSION); } #if USE_PC_MIDI /* MIDIClientRef mc; if(MIDIClientCreate(CFSTR(DEF_PRODUCT), NULL, NULL, &mc) != noErr) { printf("Could not initialize MIDI subsystem\n"); } printf("%d extern devices, %d devs\n", MIDIGetNumberOfDevices()); for(int i = 0; i < MIDIGetNumberOfDevices(); ++i) { MIDIDeviceRef dev = MIDIGetDevice(i); printf("Device %d has %d entities\n", i, MIDIDeviceGetNumberOfEntities(dev)); for(int j = 0; j < MIDIDeviceGetNumberOfEntities(dev); ++j) { MIDIEntityRef entity = MIDIDeviceGetEntity(dev, j); CFPropertyListRef props; MIDIObjectGetProperties(entity, &props, true); printf("Entity has %d prop keys\n", CFDictionaryGetCount((CFDictionaryRef)props)); int size = CFDictionaryGetCount((CFDictionaryRef)props); const void **keys = (const void **)malloc (sizeof(void *) * size); const void **vals = (const void **)malloc (sizeof(void *) * size); CFDictionaryGetKeysAndValues((CFDictionaryRef)props, keys, vals); for(int k = 0; k < size; ++k) { printf("KEY: %s' - VAL: %s\n", CFStringGetCStringPtr((CFStringRef)keys[i], 0), "hi"); } free(keys); free(vals); } } MIDIClientDispose(mc); */ #endif vstLoader *plug = new vstLoader(); if(!plug->setPath(path)) { return 1; } else { plug->setName(); } if(!plug->loadPlugin()) { delete plug; return 1; } if(!plug->initialize()) { delete plug; return 1; } // Set up time info for the plug _TIME.samplePos = 0; _TIME.sampleRate = DEF_SAMPLE_RATE; _TIME.nanoSeconds = 0; _TIME.ppqPos = 0; _TIME.tempo = DEF_TEMPO; _TIME.barStartPos = 0; _TIME.cycleStartPos = 0; _TIME.cycleEndPos = 0; _TIME.timeSigNumerator = DEF_TIMESIG_NUMER; _TIME.timeSigDenominator = DEF_TIMESIG_DENOM; _TIME.smpteOffset = 0; _TIME.smpteFrameRate = 0; _TIME.samplesToNextClock = 0; _TIME.flags = 0; // Set other plugin environment variables if(!plug->setSampleRate(DEF_SAMPLE_RATE)) { return 1; } if(!plug->setBlocksize(DEF_BLOCKSIZE)) { return 1; } // Initialize midi stuff MIDIClientRef mc; if(MIDIClientCreate(CFSTR(DEF_PRODUCT), NULL, NULL, &mc) != noErr) { debug(LOG_ERROR, "Could not initialize MIDI subsystem"); } MIDIPortRef port; err = MIDIInputPortCreate(mc, CFSTR(DEF_PRODUCT), processMidi, plug, &port); MIDIEndpointRef endpoint = MIDIGetSource(0); err = MIDIPortConnectSource(port, endpoint, NULL); int result = 0; pthread_t run_thread; result = pthread_create(&run_thread, NULL, runPluginLoop, (void*)plug); openEditor(plug->getPluginPtr()); pthread_kill(run_thread, SIGINT); MIDIPortDisconnectSource(port, endpoint); MIDIClientDispose(mc); delete plug; return 0; }
// ---------------------------------------------------------- void ofxAudioUnitMidiReceiver::disconnectFromMidiSource(unsigned long midiSourceIndex) // ---------------------------------------------------------- { OFXAU_PRINT(MIDIPortDisconnectSource(_port, MIDIGetSource(midiSourceIndex)), "disconnecting from MIDI source"); }
//_________________________________________________________ static void CloseInputSlot (SlotPtr slot) { MIDIPortDisconnectSource(gInPort, slot->src); // disconnect source }