CAMIDIEndpoints::EndpointInfoList *CAMIDIEndpoints::GetEndpoints(EMode mode, UInt32 opts) { EndpointList &srcList = (mode == kSources) ? mSources : mDestinations; EndpointInfoList *list = new EndpointInfoList; EndpointInfo info; for (EndpointList::iterator it = srcList.begin(); it != srcList.end(); ++it) { Endpoint *ept = *it; if (ept->DriverOwned()) { // driver-owned endpoint if (ept->Next() == NULL) { // nothing connected externally if ((opts & kOptIncludeUnconnectedExternalPorts) || ept->EmbeddedOrVirtual()) { if (ept->GetEndpointInfo(mode, info)) list->push_back(new EndpointInfo(info)); } } else if (opts & kOptCombineByPort) { // add one item for all connected items if (ept->GetEndpointInfo(mode, info)) list->push_back(new EndpointInfo(info)); } // else it has external connections, which we'll pick up separately } else { // external endpoint if (!(opts & kOptCombineByPort)) { if (ept->GetEndpointInfo(mode, info)) list->push_back(new EndpointInfo(info)); } } } if (opts & kOptSortByName) { std::sort(list->begin(), list->end(), CompareEndpointsByName()); } return list; }
bool CAMIDIEndpoints::FindEndpoint(EMode mode, EndpointInfo &info, UInt32 opts) { EndpointList &srcList = (mode == kSources) ? mSources : mDestinations; for (EndpointList::iterator it = srcList.begin(); it != srcList.end(); ++it) { Endpoint *ept = *it; if (ept->UniqueID() == info.mUniqueID) { if (ept->GetEndpointInfo(mode, info)) return true; break; } } info.mSourceEndpoint = NULL; info.mDestinationEndpoint = NULL; return false; }