Esempio n. 1
0
status_t _EndpointList::MidiRegistered(int32 id, AmEndpointType type)
{
	BMidiEndpoint*	endpoint = BMidiRoster::FindEndpoint(id);
	if (!endpoint) {
		ArpASSERT(false);
		return B_ERROR;
	}
	if (!endpoint->IsValid() ) return B_ERROR;
	BString			name = endpoint->Name();
	_EndpointRow*	p = ParentNamed(name, type);
	if (p) return B_OK;
	AddEndpoint(endpoint);
	return B_OK;
}
Esempio n. 2
0
status_t 
BMidiPort::Open(const char* name)
{
	fStatus = B_ERROR;

	if (name != NULL) {
		Close();

		for (int32 t = 0; t < fDevices->CountItems(); ++t) {
			BMidiEndpoint* endp = (BMidiEndpoint*) fDevices->ItemAt(t);
			if (strcmp(name, endp->Name()) != 0)
				continue;
			if (!endp->IsValid())  // still exists?
				continue;
			if (endp->IsProducer()) {
				if (fRemoteSource == NULL)
					fRemoteSource = (BMidiProducer*) endp;
			} else {
				if (fRemoteSink == NULL) {
					fRemoteSink = (BMidiConsumer*) endp;
					fLocalSource->Connect(fRemoteSink);
				}
			}
		}

		if (fRemoteSource != NULL) {
			fPortName = strdup(fRemoteSource->Name());
			fStatus = B_OK;
		} else if (fRemoteSink != NULL) {
			fPortName = strdup(fRemoteSink->Name());
			fStatus = B_OK;
		}
	}

	return fStatus;
}