Public Member Functions | List of all members
BMidiProducer Class Reference

Streams MIDI events to connected consumers. More...

Inherits BMidiEndpoint.

Inherited by BMidiLocalProducer.

Public Member Functions

status_t Connect (BMidiConsumer *cons)
 Connects a consumer to this producer. More...
 
BListConnections () const
 Returns a list with all connected consumers. More...
 
status_t Disconnect (BMidiConsumer *cons)
 Disconnects a consumer from this producer. More...
 
bool IsConnected (BMidiConsumer *cons) const
 Determines whether a consumer is connected to this producer. More...
 
- Public Member Functions inherited from BMidiEndpoint
status_t Acquire ()
 Increments the endpoint's reference count. More...
 
status_t GetProperties (BMessage *properties) const
 Reads the properties of the endpoint. More...
 
int32 ID () const
 Returns the ID of the endpoint. More...
 
bool IsConsumer () const
 Determines whether this endpoint is a BMidiConsumer. More...
 
bool IsLocal () const
 Determines whether this endpoint represents a local object. More...
 
bool IsPersistent () const
 Not used. More...
 
bool IsProducer () const
 Determines whether this endpoint is a BMidiProducer. More...
 
bool IsRemote () const
 Determines whether this endpoint is a proxy for a remote object. More...
 
bool IsValid () const
 Determines whether the endpoint still exists. More...
 
const char * Name () const
 Returns the name of the endpoint. More...
 
status_t Register ()
 Publishes the endpoint on the roster. More...
 
status_t Release ()
 Decrements the endpoint's reference count. More...
 
void SetName (const char *name)
 Changes the name of the endpoint. More...
 
status_t SetProperties (const BMessage *properties)
 Changes the properties of the endpoint. More...
 
status_t Unregister ()
 Hides the endpoint from the roster/. More...
 

Detailed Description

Streams MIDI events to connected consumers.

A producer is an object that generate a stream of MIDI events. Each producer has a list of BMidiConsumer objects to which it is connected, and may be asked to connect to or disconnect from a BMidiConsumer. A producer can spray its events to multiple consumers at the same time. A BMidiProducer either represents a local producer, i.e. a class extending from BMidiLocalProducer, or is a proxy for a remote object published by another app.

Member Function Documentation

◆ Connect()

status_t BMidiProducer::Connect ( BMidiConsumer cons)

Connects a consumer to this producer.

Establishes a connection between this producer and the specified consumer endpoint. From now on, any events that this producer sprays will be sent to that consumer. You may connect multiple consumers to a producer.

Returns
B_OK on success, or an error code when the connection could not be established. If the consumer is a proxy for a remote object and that object no longer exists, Connect() returns B_ERROR. It also returns B_ERROR if you try to connect the same producer and consumer more than once.
See also
Disconnect()

◆ Connections()

BList * BMidiProducer::Connections ( ) const

Returns a list with all connected consumers.

Returns a BList with pointers to BMidiEndpoint objects for all consumers that are connected to this producer. You can examine the contents of the list as follows:

BList* list = prod->Connections();
for (int32 t = 0; t < list->CountItems(); ++t)
{
BMidiEndpoint* endp = (BMidiEndpoint*) list->ItemAt(t);
...do stuff...
endp->Release(); // yes, here too!
}
delete list;

Every time you call this function, a new BList is allocated. The caller (that is you) is responsible for freeing this list. The BMidiEndpoint objects in the list have their reference counts bumped, so you need to Release() them before you delete the list or they will go all leaky on you.

◆ Disconnect()

status_t BMidiProducer::Disconnect ( BMidiConsumer cons)

Disconnects a consumer from this producer.

Terminates the connection between this producer and the specified consumer endpoint. From now on, any events that this producer sprays no longer go to that consumer.

Returns
B_OK on success, or an error code if there was no connection to break
See also
Connect()

◆ IsConnected()

bool BMidiProducer::IsConnected ( BMidiConsumer cons) const

Determines whether a consumer is connected to this producer.

See also
Connect()
Disconnect()