MidiClient Class Reference

Client management. More...

#include <alsaclient.h>

Inheritance diagram for MidiClient:

Inheritance graph
[legend]

List of all members.

Classes

class  SequencerInputThread
 This class manages event input from the ALSA sequencer.

Signals

void eventReceived (SequencerEvent *ev)
 Signal emitted when an event is received.

Public Member Functions

 MidiClient (QObject *parent=0)
 Constructor.
virtual ~MidiClient ()
 Destructor.
void open (const QString deviceName="default", const int openMode=SND_SEQ_OPEN_DUPLEX, const bool blockMode=false)
 Open the sequencer device.
void open (snd_config_t *conf, const QString deviceName="default", const int openMode=SND_SEQ_OPEN_DUPLEX, const bool blockMode=false)
 Open the sequencer device, providing a configuration object pointer.
void close ()
 Close the sequencer device.
void startSequencerInput ()
 Starts reading events from the ALSA sequencer.
void stopSequencerInput ()
 Stops reading events from the ALSA sequencer.
MidiPortcreatePort ()
 Create and attach a new MidiPort instance to this client.
MidiQueuecreateQueue ()
 Create and return a new MidiQueue associated to this client.
MidiQueuecreateQueue (QString const &name)
 Create and return a new MidiQueue with the given name, associated to this client.
MidiQueuegetQueue ()
 Get the MidiQueue instance associated to this client.
MidiQueueuseQueue (int queue_id)
 Create a new MidiQueue instance using a queue already existing in the system, associating it to the client.
MidiQueueuseQueue (const QString &name)
 Create a new MidiQueue instance using a queue already existing in the system, associating it to the client.
MidiQueueuseQueue (MidiQueue *queue)
 Associate an existing MidiQueue instance to the client.
void portAttach (MidiPort *port)
 Attach a MidiPort instance to this client.
void portDetach (MidiPort *port)
 Detach a MidiPort instance from this client.
void detachAllPorts ()
 Detach all the ports belonging to this client.
void addEventFilter (int evtype)
 Add an event filter to the client.
void output (SequencerEvent *ev, bool async=false, int timeout=-1)
 Output an event using the library output buffer.
void outputDirect (SequencerEvent *ev, bool async=false, int timeout=-1)
 Output an event directly to the sequencer.
void outputBuffer (SequencerEvent *ev)
 Output an event using the library output buffer, without draining the buffer.
void drainOutput (bool async=false, int timeout=-1)
 Drain the library output buffer.
void synchronizeOutput ()
 Wait until all sent events are processed.
int getClientId ()
 Gets the client ID.
snd_seq_type_t getSequencerType ()
 Returns the type snd_seq_type_t of the given sequencer handle.
snd_seq_t * getHandle ()
 Returns the sequencer handler managed by ALSA.
bool isOpened ()
 Returns true if the sequencer is opened.
size_t getOutputBufferSize ()
 Gets the size of the library output buffer for the ALSA client.
void setOutputBufferSize (size_t newSize)
 Sets the size of the library output buffer for the ALSA client.
size_t getInputBufferSize ()
 Gets the size of the library input buffer for the ALSA client.
void setInputBufferSize (size_t newSize)
 Sets the size of the library input buffer for the ALSA client.
QString getDeviceName ()
 Returns the name of the sequencer device.
int getOpenMode ()
 Returns the last open mode used in open().
bool getBlockMode ()
 Returns the last block mode used in open().
void setBlockMode (bool newValue)
 Change the blocking mode of the client.
QString getClientName ()
 Gets the client's public name.
QString getClientName (const int clientId)
 Gets the public name corresponding to the given Client ID.
void setClientName (QString const &newName)
 Changes the public name of the ALSA sequencer client.
bool getBroadcastFilter ()
 Gets the broadcast filter usage of the client.
void setBroadcastFilter (bool newValue)
 Sets the broadcast filter usage of the client.
bool getErrorBounce ()
 Get the error-bounce usage of the client.
void setErrorBounce (bool newValue)
 Sets the error-bounce usage of the client.
ClientInfogetThisClientInfo ()
 Gets the ClientInfo object holding data about this client.
void setThisClientInfo (const ClientInfo &val)
 Sets the data supplied by the ClientInfo object into the ALSA sequencer client.
MidiPortList getMidiPorts () const
 Gets the list of MidiPort instances belonging to this client.
ClientInfoList getAvailableClients ()
 Gets the list of clients from the ALSA sequencer.
PortInfoList getAvailableInputs ()
 Gets the available user input ports in the system.
PortInfoList getAvailableOutputs ()
 Gets the available user output ports in the system.
SystemInfogetSystemInfo ()
 Gets a SystemInfo instance with the updated state of the system.
QList< int > getAvailableQueues ()
 Get a list of the existing queues.
PoolInfogetPoolInfo ()
 Gets a PoolInfo instance with an updated state of the client memory pool.
void setPoolInfo (const PoolInfo &info)
 Applies (updates) the client's PoolInfo data into the system.
void setPoolInput (int size)
 Sets the size of the client's input pool.
void setPoolOutput (int size)
 Sets the size of the client's output pool.
void setPoolOutputRoom (int size)
 Sets the room size of the client's output pool.
void resetPoolInput ()
 Resets the client input pool.
void resetPoolOutput ()
 Resets the client output pool.
void dropInput ()
 Clears the client's input buffer and and remove events in sequencer queue.
void dropInputBuffer ()
 Remove all events on user-space input buffer.
void dropOutput ()
 Clears the client's output buffer and and remove events in sequencer queue.
void dropOutputBuffer ()
 Removes all events on the library output buffer.
void removeEvents (const RemoveEvents *spec)
 Removes events on input/output buffers and pools.
SequencerEventextractOutput ()
 Extracts (and removes) the first event in the output buffer.
int outputPending ()
 Returns the size of pending events on the output buffer.
int inputPending (bool fetch)
 Gets the size of the events on the input buffer.
int getQueueId (const QString &name)
 Gets the queue's numeric identifier corresponding to the provided name.
void addListener (QObject *listener)
 Adds a QObject to the listeners list.
void removeListener (QObject *listener)
 Removes a QObject listener from the listeners list.
void setEventsEnabled (const bool bEnabled)
 Enables the notification of received SequencerEvent instances to the listeners registered with addListener().
bool getEventsEnabled () const
 Returns true if the events mode of delivery has been enabled.
void setHandler (SequencerEventHandler *handler)
 Sets a sequencer event handler enabling the callback delivery mode.
bool parseAddress (const QString &straddr, snd_seq_addr &result)
 Parse a text address representation, returning an ALSA address record.

Protected Member Functions

void doEvents ()
 Dispatch the events received from the Sequencer.
void applyClientInfo ()
 This internal method applies the ClientInfo data to the ALSA sequencer client.
void readClients ()
 Reads the ALSA sequencer's clients list.
void freeClients ()
 Releases the list of ALSA sequencer's clients.
void updateAvailablePorts ()
 Update the internal lists of user ports.
PortInfoList filterPorts (unsigned int filter)
 Gets a list of the available user ports in the system, filtered by the given bitmap of desired capabilities.
const char * _getDeviceName ()
 Gets the internal sequencer device name.
int getPollDescriptorsCount (short events)
 Returns the number of poll descriptors.
int pollDescriptors (struct pollfd *pfds, unsigned int space, short events)
 Get poll descriptors.
unsigned short pollDescriptorsRevents (struct pollfd *pfds, unsigned int nfds)
 Gets the number of returned events from poll descriptors.
void _setClientName (const char *name)
 Sets the client name.
int createSimplePort (const char *name, unsigned int caps, unsigned int type)
 Create an ALSA sequencer port, without using MidiPort.
void deleteSimplePort (int port)
 Remove an ALSA sequencer port.
void connectFrom (int myport, int client, int port)
 Subscribe one port from another arbitrary sequencer client:port.
void connectTo (int myport, int client, int port)
 Subscribe one port to another arbitrary sequencer client:port.
void disconnectFrom (int myport, int client, int port)
 Unsubscribe one port from another arbitrary sequencer client:port.
void disconnectTo (int myport, int client, int port)
 Unsubscribe one port to another arbitrary sequencer client:port.


Detailed Description

Client management.

This class represents an ALSA sequencer client

Examples:

drumgrid.cpp, dumpmid.cpp, guiplayer.cpp, metronome.cpp, playsmf.cpp, sysinfo.cpp, and vpiano.cpp.

Definition at line 198 of file alsaclient.h.


Constructor & Destructor Documentation

MidiClient ( QObject parent = 0  ) 

Constructor.

This constructor optionally gets a QObject parent. When you create a MidiClient with another object as parent, the MidiClient object will automatically add itself to the parent's children() list. The parent takes ownership of the object i.e. it will automatically delete its children in its destructor.

It is necessary to invoke open() later to get the sequencer client handler from the ALSA sequencer subsystem.

Parameters:
parent The optional parent object
Returns:
a MidiClient instance

Definition at line 318 of file alsaclient.cpp.

~MidiClient (  )  [virtual]

Destructor.

The ports and queue associated to this client are automatically released.

Definition at line 336 of file alsaclient.cpp.

References MidiClient::close(), MidiClient::detachAllPorts(), MidiClient::freeClients(), and MidiClient::stopSequencerInput().


Member Function Documentation

const char * _getDeviceName (  )  [protected]

Gets the internal sequencer device name.

Returns:
The device name.

Definition at line 1542 of file alsaclient.cpp.

void _setClientName ( const char *  name  )  [protected]

Sets the client name.

Parameters:
name The new client name.

Definition at line 1552 of file alsaclient.cpp.

References CHECK_WARNING.

void addEventFilter ( int  evtype  ) 

Add an event filter to the client.

Parameters:
evtype An event filter to be added.

Definition at line 903 of file alsaclient.cpp.

void addListener ( QObject listener  ) 

Adds a QObject to the listeners list.

This object should override the method QObject::customEvent() to receive SequencerEvent instances.

Parameters:
listener A QObject listener to be notified of received events.
See also:
removeListener(), setEventsEnabled()

Definition at line 1263 of file alsaclient.cpp.

void applyClientInfo (  )  [protected]

This internal method applies the ClientInfo data to the ALSA sequencer client.

Definition at line 772 of file alsaclient.cpp.

Referenced by MidiClient::setBroadcastFilter(), MidiClient::setClientName(), and MidiClient::setErrorBounce().

void close (  ) 

Close the sequencer device.

After a client is closed, an event with SND_SEQ_EVENT_CLIENT_EXIT is broadcast to the announce port. The connection between other clients are disconnected. Call this just before exiting your program.

Definition at line 426 of file alsaclient.cpp.

References CHECK_WARNING, and MidiClient::stopSequencerInput().

Referenced by MidiClient::~MidiClient().

void connectFrom ( int  myport,
int  client,
int  port 
) [protected]

Subscribe one port from another arbitrary sequencer client:port.

Parameters:
myport The number of the internal port.
client The external client's identifier.
port The external port's identifier.

Definition at line 1590 of file alsaclient.cpp.

References CHECK_WARNING.

void connectTo ( int  myport,
int  client,
int  port 
) [protected]

Subscribe one port to another arbitrary sequencer client:port.

Parameters:
myport The number of the internal port.
client The external client's identifier.
port The external port's identifier.

Definition at line 1602 of file alsaclient.cpp.

References CHECK_WARNING.

MidiPort * createPort (  ) 

Create and attach a new MidiPort instance to this client.

Returns:
The pointer to the new MidiPort instance.

Definition at line 836 of file alsaclient.cpp.

References MidiPort::attach().

MidiQueue * createQueue ( QString const &  queueName  ) 

Create and return a new MidiQueue with the given name, associated to this client.

Parameters:
queueName The name for the new queue.
Returns:
A new MidiQueue instance.

Definition at line 1099 of file alsaclient.cpp.

MidiQueue * createQueue (  ) 

Create and return a new MidiQueue associated to this client.

Returns:
A new MidiQueue instance.

Definition at line 1083 of file alsaclient.cpp.

Referenced by MidiClient::getQueue().

int createSimplePort ( const char *  name,
unsigned int  caps,
unsigned int  type 
) [protected]

Create an ALSA sequencer port, without using MidiPort.

Parameters:
name The name of the new port.
caps The new port capabilities.
type The type of the new port.
Returns:
The port numeric identifier.

Definition at line 1565 of file alsaclient.cpp.

References CHECK_WARNING.

void deleteSimplePort ( int  port  )  [protected]

Remove an ALSA sequencer port.

Parameters:
port The numeric identifier of the port.

Definition at line 1578 of file alsaclient.cpp.

References CHECK_WARNING.

void detachAllPorts (  ) 

Detach all the ports belonging to this client.

Definition at line 886 of file alsaclient.cpp.

References CHECK_ERROR.

Referenced by MidiClient::~MidiClient().

void disconnectFrom ( int  myport,
int  client,
int  port 
) [protected]

Unsubscribe one port from another arbitrary sequencer client:port.

Parameters:
myport The number of the internal port.
client The external client's identifier.
port The external port's identifier.

Definition at line 1614 of file alsaclient.cpp.

References CHECK_WARNING.

void disconnectTo ( int  myport,
int  client,
int  port 
) [protected]

Unsubscribe one port to another arbitrary sequencer client:port.

Parameters:
myport The number of the internal port.
client The external client's identifier.
port The external port's identifier.

Definition at line 1626 of file alsaclient.cpp.

References CHECK_WARNING.

void doEvents (  )  [protected]

Dispatch the events received from the Sequencer.

There are three methods of events delivering:

  • A Callback method. To use this method, you must derive a class from SequencerEventHandler, overriding the method SequencerEventHandler::handleSequencerEvent() to provide your own event processing. You must provide the handler instance to the client using setHandler().
  • Using QEvent listeners. To use this method, you must use one or more classes derived from QObject overriding the method QObject::customEvent(). You must also use the method addListener() to add such objects to the client's listeners list.
  • The third method involves signals and slots. Whenever a sequencer event is received, a signal eventReceived() is emitted, that can be connected to your own supplied slot(s) to process it.
See also:
ALSA Sequencer Clients

Definition at line 562 of file alsaclient.cpp.

References MidiClient::eventReceived(), and SequencerEventHandler::handleSequencerEvent().

void drainOutput ( bool  async = false,
int  timeout = -1 
)

Drain the library output buffer.

This function drains all pending events on the output buffer. The function returns immediately after the events are sent to the queues regardless whether the events are processed or not.

Parameters:
async Use asynchronous mode. If false, this call will block until the buffer can be flushed.
timeout The maximum time to wait in synchronous mode.

Definition at line 1036 of file alsaclient.cpp.

References CHECK_WARNING.

void dropInput (  ) 

Clears the client's input buffer and and remove events in sequencer queue.

See also:
resetPoolInput()

Definition at line 1381 of file alsaclient.cpp.

References CHECK_WARNING.

void dropInputBuffer (  ) 

Remove all events on user-space input buffer.

See also:
dropInput()

Definition at line 1391 of file alsaclient.cpp.

References CHECK_WARNING.

void dropOutput (  ) 

Clears the client's output buffer and and remove events in sequencer queue.

This method removes all events on both user-space output buffer and output memory pool on kernel.

See also:
resetPoolOutput()

Definition at line 1404 of file alsaclient.cpp.

References CHECK_WARNING.

void dropOutputBuffer (  ) 

Removes all events on the library output buffer.

Removes all events on the user-space output buffer. Unlike dropOutput(), this method doesn't remove events on the client's output memory pool.

See also:
dropOutput()

Definition at line 1417 of file alsaclient.cpp.

References CHECK_WARNING.

void eventReceived ( SequencerEvent ev  )  [signal]

Signal emitted when an event is received.

Referenced by MidiClient::doEvents().

SequencerEvent * extractOutput (  ) 

Extracts (and removes) the first event in the output buffer.

Returns:
The extracted event.

Definition at line 1439 of file alsaclient.cpp.

References CHECK_WARNING.

PortInfoList filterPorts ( unsigned int  filter  )  [protected]

Gets a list of the available user ports in the system, filtered by the given bitmap of desired capabilities.

Parameters:
filter A bitmap of capabilities.
Returns:
A filtered list of the available ports in the system.

Definition at line 1191 of file alsaclient.cpp.

References PortInfo::getCapability(), ClientInfo::getClientId(), ClientInfo::getPorts(), and MidiClient::readClients().

Referenced by MidiClient::updateAvailablePorts().

void freeClients (  )  [protected]

Releases the list of ALSA sequencer's clients.

Definition at line 725 of file alsaclient.cpp.

Referenced by MidiClient::readClients(), and MidiClient::~MidiClient().

ClientInfoList getAvailableClients (  ) 

Gets the list of clients from the ALSA sequencer.

Returns:
the list of clients.
Examples:
sysinfo.cpp.

Definition at line 735 of file alsaclient.cpp.

References MidiClient::readClients().

PortInfoList getAvailableInputs (  ) 

Gets the available user input ports in the system.

Returns:
The list of available input ports.

Definition at line 1237 of file alsaclient.cpp.

References MidiClient::updateAvailablePorts().

PortInfoList getAvailableOutputs (  ) 

Gets the available user output ports in the system.

Returns:
The list of available output ports.

Definition at line 1249 of file alsaclient.cpp.

References MidiClient::updateAvailablePorts().

QList< int > getAvailableQueues (  ) 

Get a list of the existing queues.

Returns:
a list of existing queues
Examples:
sysinfo.cpp.

Definition at line 1167 of file alsaclient.cpp.

References SystemInfo::getMaxQueues(), and MidiClient::getSystemInfo().

bool getBlockMode (  )  [inline]

Returns the last block mode used in open().

Definition at line 272 of file alsaclient.h.

bool getBroadcastFilter (  ) 

Gets the broadcast filter usage of the client.

Returns:
The broadcast filter.

Definition at line 914 of file alsaclient.cpp.

References ClientInfo::getBroadcastFilter().

int getClientId (  ) 

Gets the client ID.

Returns the ID of the client. A client ID is necessary to inquiry or to set the client information. A user client ID is assigned from 128 to 191.

Returns:
the client ID.

Definition at line 526 of file alsaclient.cpp.

References CHECK_WARNING.

Referenced by MidiClient::portDetach(), and SequencerOutputThread::sendEchoEvent().

QString getClientName ( const int  clientId  ) 

Gets the public name corresponding to the given Client ID.

Parameters:
clientId The ID of any existing sequencer client
Returns:
The client's name

Definition at line 795 of file alsaclient.cpp.

References MidiClient::readClients().

QString getClientName (  ) 

Gets the client's public name.

Returns:
The client's name

Definition at line 784 of file alsaclient.cpp.

References ClientInfo::getName().

Referenced by MidiPort::getReadSubscribers(), and MidiPort::getWriteSubscribers().

QString getDeviceName (  )  [inline]

Returns the name of the sequencer device.

Definition at line 268 of file alsaclient.h.

bool getErrorBounce (  ) 

Get the error-bounce usage of the client.

Returns:
The error-bounce usage.

Definition at line 937 of file alsaclient.cpp.

References ClientInfo::getErrorBounce().

bool getEventsEnabled (  )  const [inline]

Returns true if the events mode of delivery has been enabled.

Definition at line 312 of file alsaclient.h.

snd_seq_t* getHandle (  )  [inline]

size_t getInputBufferSize (  ) 

Gets the size of the library input buffer for the ALSA client.

This buffer is used to read a byte-stream of input events before transferring from the sequencer.

Returns:
the size of the library input buffer

Definition at line 474 of file alsaclient.cpp.

Referenced by MidiClient::setInputBufferSize().

MidiPortList getMidiPorts (  )  const

Gets the list of MidiPort instances belonging to this client.

Returns:
The list of MidiPort instances.

Definition at line 826 of file alsaclient.cpp.

int getOpenMode (  )  [inline]

Returns the last open mode used in open().

Definition at line 270 of file alsaclient.h.

size_t getOutputBufferSize (  ) 

Gets the size of the library output buffer for the ALSA client.

This buffer is used to store the decoded byte-stream of output events before transferring to the sequencer.

Returns:
the size of the library output buffer

Definition at line 444 of file alsaclient.cpp.

Referenced by MidiClient::setOutputBufferSize().

int getPollDescriptorsCount ( short  events  )  [protected]

Returns the number of poll descriptors.

Parameters:
events Poll events to be checked (POLLIN and POLLOUT).
Returns:
The number of poll descriptors.

Definition at line 1496 of file alsaclient.cpp.

PoolInfo & getPoolInfo (  ) 

Gets a PoolInfo instance with an updated state of the client memory pool.

Returns:
The updated memory pool state.

Definition at line 1309 of file alsaclient.cpp.

MidiQueue * getQueue (  ) 

Get the MidiQueue instance associated to this client.

If the client is not associated to a MidiQueue, one is created.

Returns:
A MidiQueue instance pointer

Definition at line 1070 of file alsaclient.cpp.

References MidiClient::createQueue().

Referenced by SequencerOutputThread::SequencerOutputThread().

int getQueueId ( const QString &  name  ) 

Gets the queue's numeric identifier corresponding to the provided name.

Parameters:
name The name string to query.
Returns:
The number of the matching queue.

Definition at line 1485 of file alsaclient.cpp.

Referenced by MidiClient::useQueue().

snd_seq_type_t getSequencerType (  ) 

Returns the type snd_seq_type_t of the given sequencer handle.

Returns:
the type snd_seq_type_t of the given sequencer handle.

Definition at line 536 of file alsaclient.cpp.

SystemInfo & getSystemInfo (  ) 

Gets a SystemInfo instance with the updated state of the system.

Returns:
The updated system info.
Examples:
sysinfo.cpp.

Definition at line 1298 of file alsaclient.cpp.

Referenced by MidiClient::getAvailableQueues().

ClientInfo & getThisClientInfo (  ) 

Gets the ClientInfo object holding data about this client.

Returns:
the ClientInfo object representing this client.

Definition at line 748 of file alsaclient.cpp.

int inputPending ( bool  fetch  ) 

Gets the size of the events on the input buffer.

If there are events remaining on the user-space input buffer, this method returns the total size of events on it. If the argument is true, this method checks the presence of events on the sequencer FIFO, and when events exist they are transferred to the input buffer, and the number of received events are returned. If the argument is false and no events remain on the input buffer, this method simply returns zero.

Parameters:
fetch Check and fetch the sequencer input pool.
Returns:
The size in bytes of the remaining input events on the buffer.

Definition at line 1473 of file alsaclient.cpp.

bool isOpened (  )  [inline]

Returns true if the sequencer is opened.

Definition at line 261 of file alsaclient.h.

Referenced by MidiPort::applyPortInfo(), Subscription::subscribe(), and Subscription::unsubscribe().

void open ( snd_config_t *  conf,
const QString  deviceName = "default",
const int  openMode = SND_SEQ_OPEN_DUPLEX,
const bool  blockMode = false 
)

Open the sequencer device, providing a configuration object pointer.

This method is like open() except that a configuration is explicitly provided. After a successful open, an event with SND_SEQ_EVENT_CLIENT_START type is broadcasted from the announce port.

Parameters:
conf a configuration object pointer.
deviceName the sequencer device name, default value = "default". This is not a name you make up for your own purposes; it has special significance to the ALSA library. Usually you need to pass "default" here.
openMode the open mode, default value = SND_SEQ_OPEN_DUPLEX. The read/write mode of the sequencer. Can be one of these three values:
  • SND_SEQ_OPEN_OUTPUT - open the sequencer for output only
  • SND_SEQ_OPEN_INPUT - open the sequencer for input only
  • SND_SEQ_OPEN_DUPLEX - open the sequencer for output and input
blockMode open in blocking mode, default value = false.

Definition at line 402 of file alsaclient.cpp.

References CHECK_ERROR, and CHECK_WARNING.

void open ( const QString  deviceName = "default",
const int  openMode = SND_SEQ_OPEN_DUPLEX,
const bool  blockMode = false 
)

Open the sequencer device.

When opening the MidiClient instance, several properties may optionally be set as the device name, the open mode and block mode. Default values are provided for them. After a successful open, an event with SND_SEQ_EVENT_CLIENT_START is broadcast to the announce port.

Parameters:
deviceName the sequencer device name, default value = "default". This is not a name you make up for your own purposes; it has special significance to the ALSA library. Usually you need to pass "default" here.
openMode the open mode, default value = SND_SEQ_OPEN_DUPLEX. The read/write mode of the sequencer. Can be one of these three values:
  • SND_SEQ_OPEN_OUTPUT - open the sequencer for output only
  • SND_SEQ_OPEN_INPUT - open the sequencer for input only
  • SND_SEQ_OPEN_DUPLEX - open the sequencer for output and input
blockMode open in blocking mode, default value = false.
Examples:
sysinfo.cpp.

Definition at line 369 of file alsaclient.cpp.

References CHECK_ERROR, and CHECK_WARNING.

void output ( SequencerEvent ev,
bool  async = false,
int  timeout = -1 
)

Output an event using the library output buffer.

An event is once expanded on the output buffer. The output buffer will be drained automatically if it becomes full.

Parameters:
ev The event to be sent.
async Use asynchronous mode. If false, this call will block until the event can be delivered.
timeout The maximum time to wait in synchronous mode.

Definition at line 966 of file alsaclient.cpp.

References CHECK_WARNING, and SequencerEvent::getHandle().

void outputBuffer ( SequencerEvent ev  ) 

Output an event using the library output buffer, without draining the buffer.

An event is once expanded on the output buffer. The output buffer will NOT be drained automatically if it becomes full.

Parameters:
ev The event to be sent.

Definition at line 1020 of file alsaclient.cpp.

References CHECK_WARNING, and SequencerEvent::getHandle().

void outputDirect ( SequencerEvent ev,
bool  async = false,
int  timeout = -1 
)

Output an event directly to the sequencer.

This function sends an event to the sequencer directly not using the library output buffer.

Parameters:
ev The event to be sent.
async Use asynchronous mode. If false, this call will block until the event is delivered to the sequencer.
timeout The maximum time to wait in synchronous mode.

Definition at line 994 of file alsaclient.cpp.

References CHECK_WARNING, and SequencerEvent::getHandle().

Referenced by MidiQueue::setRealTimePosition(), and MidiQueue::setTickPosition().

int outputPending (  ) 

Returns the size of pending events on the output buffer.

Returns:
The size of pending events.

Definition at line 1454 of file alsaclient.cpp.

bool parseAddress ( const QString &  straddr,
snd_seq_addr &  addr 
)

Parse a text address representation, returning an ALSA address record.

This function can be used as a replacement of the standard ALSA function snd_seq_parse_address().

Parameters:
straddr source text address representation
addr returned ALSA address record
Returns:
true if the text address was successfully parsed

Definition at line 1642 of file alsaclient.cpp.

References ClientInfo::getClientId(), ClientInfo::getName(), and MidiClient::readClients().

Referenced by MidiPort::subscribeFrom(), MidiPort::subscribeTo(), MidiPort::unsubscribeFrom(), and MidiPort::unsubscribeTo().

int pollDescriptors ( struct pollfd *  pfds,
unsigned int  space,
short  events 
) [protected]

Get poll descriptors.

Get poll descriptors assigned to the sequencer handle. Since a sequencer handle can duplex streams, you need to set which direction(s) is/are polled in events argument. When POLLIN bit is specified, the incoming events to the ports are checked.

Parameters:
pfds Array of poll descriptors
space Space in the poll descriptor array
events Polling events to be checked (POLLIN and POLLOUT)
Returns:
Count of filled descriptors

Definition at line 1515 of file alsaclient.cpp.

unsigned short pollDescriptorsRevents ( struct pollfd *  pfds,
unsigned int  nfds 
) [protected]

Gets the number of returned events from poll descriptors.

Parameters:
pfds Array of poll descriptors.
nfds Count of poll descriptors.
Returns:
Number of returned events.

Definition at line 1528 of file alsaclient.cpp.

References CHECK_WARNING.

void portAttach ( MidiPort port  ) 

Attach a MidiPort instance to this client.

Parameters:
port The MidiPort to be attached

Definition at line 848 of file alsaclient.cpp.

References CHECK_ERROR.

Referenced by MidiPort::attach().

void portDetach ( MidiPort port  ) 

Detach a MidiPort instance from this client.

Parameters:
port The MidiPort to be detached

Definition at line 861 of file alsaclient.cpp.

References CHECK_ERROR, PortInfo::getClient(), MidiClient::getClientId(), PortInfo::getPort(), MidiPort::getPortInfo(), and MidiPort::setMidiClient().

Referenced by MidiPort::detach().

void readClients (  )  [protected]

void removeEvents ( const RemoveEvents spec  ) 

Removes events on input/output buffers and pools.

Removes matching events with the given condition from input/output buffers and pools. The removal condition is specified in the spec argument.

Parameters:
spec A RemoveEvents instance specifying the removal condition.

Definition at line 1429 of file alsaclient.cpp.

References CHECK_WARNING.

void removeListener ( QObject listener  ) 

Removes a QObject listener from the listeners list.

Parameters:
listener listener A QObject listener to be removed of received events.
See also:
addListener(), setEventsEnabled()

Definition at line 1274 of file alsaclient.cpp.

void resetPoolInput (  ) 

Resets the client input pool.

See also:
dropInput()

Definition at line 1331 of file alsaclient.cpp.

References CHECK_WARNING.

void resetPoolOutput (  ) 

Resets the client output pool.

See also:
dropOutput()

Definition at line 1341 of file alsaclient.cpp.

References CHECK_WARNING.

void setBlockMode ( bool  newValue  ) 

Change the blocking mode of the client.

In block mode, the client falls into sleep when it fills the output memory pool with full events. The client will be woken up after a certain amount of free space becomes available.

Parameters:
newValue the blocking mode

Definition at line 505 of file alsaclient.cpp.

References CHECK_WARNING.

void setBroadcastFilter ( bool  newValue  ) 

Sets the broadcast filter usage of the client.

Parameters:
newValue The broadcast filter.

Definition at line 925 of file alsaclient.cpp.

References MidiClient::applyClientInfo(), and ClientInfo::setBroadcastFilter().

void setClientName ( QString const &  newName  ) 

Changes the public name of the ALSA sequencer client.

Parameters:
newName A new public name
Examples:
sysinfo.cpp.

Definition at line 813 of file alsaclient.cpp.

References MidiClient::applyClientInfo(), ClientInfo::getName(), and ClientInfo::setName().

void setErrorBounce ( bool  newValue  ) 

Sets the error-bounce usage of the client.

Parameters:
newValue The error-bounce usage.

Definition at line 948 of file alsaclient.cpp.

References MidiClient::applyClientInfo(), and ClientInfo::setErrorBounce().

void setEventsEnabled ( const bool  bEnabled  ) 

Enables the notification of received SequencerEvent instances to the listeners registered with addListener().

Parameters:
bEnabled The new state of the events delivering mode.
See also:
addListener(), removeListener(), setEventsEnabled()

Definition at line 1286 of file alsaclient.cpp.

void setHandler ( SequencerEventHandler handler  )  [inline]

Sets a sequencer event handler enabling the callback delivery mode.

Definition at line 314 of file alsaclient.h.

void setInputBufferSize ( size_t  newSize  ) 

Sets the size of the library input buffer for the ALSA client.

This buffer is used to read a byte-stream of input events before transferring from the sequencer.

Parameters:
newSize the size of the library input buffer

Definition at line 488 of file alsaclient.cpp.

References CHECK_WARNING, and MidiClient::getInputBufferSize().

void setOutputBufferSize ( size_t  newSize  ) 

Sets the size of the library output buffer for the ALSA client.

This buffer is used to store the decoded byte-stream of output events before transferring to the sequencer.

Parameters:
newSize the size of the library output buffer

Definition at line 458 of file alsaclient.cpp.

References CHECK_WARNING, and MidiClient::getOutputBufferSize().

void setPoolInfo ( const PoolInfo info  ) 

Applies (updates) the client's PoolInfo data into the system.

Parameters:
info The PoolInfo reference to be applied to the client.

Definition at line 1320 of file alsaclient.cpp.

References CHECK_WARNING.

void setPoolInput ( int  size  ) 

Sets the size of the client's input pool.

Parameters:
size The new size

Definition at line 1351 of file alsaclient.cpp.

References CHECK_WARNING.

void setPoolOutput ( int  size  ) 

Sets the size of the client's output pool.

Parameters:
size The new size

Definition at line 1361 of file alsaclient.cpp.

References CHECK_WARNING.

void setPoolOutputRoom ( int  size  ) 

Sets the room size of the client's output pool.

Parameters:
size The new size

Definition at line 1371 of file alsaclient.cpp.

References CHECK_WARNING.

void setThisClientInfo ( const ClientInfo val  ) 

Sets the data supplied by the ClientInfo object into the ALSA sequencer client.

This allows to change the name, capabilities, type and other data in a single step.

Parameters:
val a ClientInfo object reference

Definition at line 762 of file alsaclient.cpp.

void startSequencerInput (  ) 

Starts reading events from the ALSA sequencer.

Definition at line 678 of file alsaclient.cpp.

void stopSequencerInput (  ) 

Stops reading events from the ALSA sequencer.

Definition at line 690 of file alsaclient.cpp.

Referenced by MidiClient::close(), and MidiClient::~MidiClient().

void synchronizeOutput (  ) 

Wait until all sent events are processed.

This function waits until all events of this client are processed.

Definition at line 1059 of file alsaclient.cpp.

void updateAvailablePorts (  )  [protected]

Update the internal lists of user ports.

Definition at line 1222 of file alsaclient.cpp.

References MidiClient::filterPorts().

Referenced by MidiClient::getAvailableInputs(), and MidiClient::getAvailableOutputs().

MidiQueue * useQueue ( MidiQueue queue  ) 

Associate an existing MidiQueue instance to the client.

Parameters:
queue An existing MidiQueue.
Returns:
The provided MidiQueue instance.

Definition at line 1152 of file alsaclient.cpp.

MidiQueue * useQueue ( const QString &  name  ) 

Create a new MidiQueue instance using a queue already existing in the system, associating it to the client.

Parameters:
name An existing queue name.
Returns:
A new MidiQueue instance.

Definition at line 1133 of file alsaclient.cpp.

References MidiClient::getQueueId().

MidiQueue * useQueue ( int  queue_id  ) 

Create a new MidiQueue instance using a queue already existing in the system, associating it to the client.

Parameters:
queue_id An existing queue identifier.
Returns:
A new MidiQueue instance.

Definition at line 1116 of file alsaclient.cpp.


The documentation for this class was generated from the following files:

Generated on Wed Sep 8 10:12:37 2010 for drumstick by  doxygen 1.5.9