Esempio n. 1
0
void 
BMidiPort::ScanDevices()
{
	EmptyDeviceList();

	int32 id = 0;
	BMidiEndpoint* endp;

	while ((endp = BMidiRoster::NextEndpoint(&id)) != NULL) {
		// Each hardware port has two endpoints associated with it, a consumer
		// and a producer. Both have the same name, so we add only one of them.

		bool addItem = true;
		for (int32 t = 0; t < fDevices->CountItems(); ++t) {
			BMidiEndpoint* other = (BMidiEndpoint*) fDevices->ItemAt(t);
			if (strcmp(endp->Name(), other->Name()) == 0) {
				addItem = false;
				break;
			}
		}

		if (addItem) {
			fDevices->AddItem(endp);
		} else {
			endp->Release();
		}
	}
}
Esempio n. 2
0
void MidiPlayerWindow::MenusBeginning()
{
    for (int32 t = inputPopUp->CountItems() - 1; t > 0; --t)
    {
        delete inputPopUp->RemoveItem(t);
    }

    // Note: if the selected endpoint no longer exists, then no endpoint is
    // marked. However, we won't disconnect it until you choose another one.

    inputOff->SetMarked(inputId == -1);

    int32 id = 0;
    BMidiEndpoint* endp;
    while ((endp = BMidiRoster::NextEndpoint(&id)) != NULL)
    {
        if (endp->IsProducer())
        {
            BMessage* msg = new BMessage;
            msg->what = MSG_INPUT_CHANGED;
            msg->AddInt32("id", id);

            BMenuItem* item = new BMenuItem(endp->Name(), msg);
            inputPopUp->AddItem(item);
            item->SetMarked(inputId == id);
        }

        endp->Release();
    }
}
Esempio n. 3
0
bool
PatchView::GetToolTipAt(BPoint point, BToolTip** tip)
{
	bool found = false;
	int32 index = 0;
	endpoint_itor begin, end;
	int32 size = fConsumers.size();
	for (int32 i = 0; !found && i < size; i++) {
		BRect r = ColumnIconFrameAt(i);
		if (r.Contains(point)) {
			begin = fConsumers.begin();
			end = fConsumers.end();
			found = true;
			index = i;
		}
	}
	size = fProducers.size();
	for (int32 i = 0; !found && i < size; i++) {
		BRect r = RowIconFrameAt(i);
		if (r.Contains(point)) {
			begin = fProducers.begin();
			end = fProducers.end();
			found = true;
			index = i;
		}
	}
	
	if (!found)
		return false;

	endpoint_itor itor;
	for (itor = begin; itor != end; itor++, index--)
		if (index <= 0)
			break;
	
	if (itor == end)
		return false;

	BMidiRoster* roster = BMidiRoster::MidiRoster();
	if (roster == NULL)
		return false;
	BMidiEndpoint* obj = roster->FindEndpoint(itor->ID());
	if (obj == NULL)
		return false;

	BString str;
	str << "<" << obj->ID() << ">: " << obj->Name();
	obj->Release();

	SetToolTip(str.String());

	*tip = ToolTip();

	return true;
}
Esempio n. 4
0
BMidiConsumer* 
BMidiRoster::FindConsumer(int32 id, bool localOnly)
{
	BMidiEndpoint* endp = FindEndpoint(id, localOnly);

	if ((endp != NULL) && !endp->IsConsumer()) {
		endp->Release();
		endp = NULL;
	}

	return (BMidiConsumer*) endp;
}
Esempio n. 5
0
BMidiConsumer* 
BMidiRoster::NextConsumer(int32* id)
{
	BMidiEndpoint* endp;

	while ((endp = NextEndpoint(id)) != NULL) {
		if (endp->IsConsumer()) {
			return (BMidiConsumer*) endp;
		}
		endp->Release();
	}

	return NULL;
}
Esempio n. 6
0
EndpointInfo::EndpointInfo(int32 id)
    : m_id(id), m_icon(NULL)
{
    BMidiRoster* roster = BMidiRoster::MidiRoster();
    if (roster) {
        BMidiEndpoint* endpoint = roster->FindEndpoint(id);
        if (endpoint) {
            printf("endpoint %ld = %p\n", id, endpoint);
            BMessage msg;
            if (endpoint->GetProperties(&msg) == B_OK) {
                m_icon = CreateIcon(&msg, DISPLAY_ICON_SIZE);
            }
            endpoint->Release();
        }
    }
}