Пример #1
0
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;
}
Пример #2
0
bool CAMIDIEndpoints::Endpoint::GetEndpointInfo(EMode mode, EndpointInfo &info) {
    Endpoint *ept = this, *ept2;
    if (mode == kPairs) {
        if ((ept2 = ept->PairMate()) == NULL)
            return false;
        info.mSourceEndpoint = ept2->IOEndpoint();
        info.mDestinationEndpoint = ept->IOEndpoint();
    }
    else if (mode == kSources) {
        info.mSourceEndpoint = ept->IOEndpoint();
        info.mDestinationEndpoint = NULL;
    }
    else {
        info.mSourceEndpoint = NULL;
        info.mDestinationEndpoint = ept->IOEndpoint();
    }
    info.mUniqueID = ept->UniqueID();
    
    if (ept->DriverOwned() && ept->Next() != NULL) {
        // add one item for all connected items
        CFMutableStringRef names = CFStringCreateMutable(NULL, 0);
        bool first = true;
        while (true) {
            ept = ept->Next();
            if (ept == NULL)
                break;
            if (!first) {
                CFStringAppend(names, CFSTR(", "));
            }
            else first = false;
            CFStringAppend(names, ept->Name());
        }
        info.mDisplayName = names;
    }
    else {
        // a driver-owned endpoint with nothing connected externally,
        // or an external endpoint
        CFRetain(info.mDisplayName = ept->Name());
    }
    return true;
}