drumstick  0.5.0
MidiClient Class Reference

Client management. More...

#include <alsaclient.h>

Inheritance diagram for MidiClient:

Classes

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

Signals

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

Public Member Functions

 MidiClient (QObject *parent=0)
 Constructor. More...
 
virtual ~MidiClient ()
 Destructor. More...
 
void open (const QString deviceName="default", const int openMode=SND_SEQ_OPEN_DUPLEX, const bool blockMode=false)
 Open the sequencer device. More...
 
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. More...
 
void close ()
 Close the sequencer device. More...
 
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. More...
 
MidiQueuecreateQueue ()
 Create and return a new MidiQueue associated to this client. More...
 
MidiQueuecreateQueue (QString const &name)
 Create and return a new MidiQueue with the given name, associated to this client. More...
 
MidiQueuegetQueue ()
 Get the MidiQueue instance associated to this client. More...
 
MidiQueueuseQueue (int queue_id)
 Create a new MidiQueue instance using a queue already existing in the system, associating it to the client. More...
 
MidiQueueuseQueue (const QString &name)
 Create a new MidiQueue instance using a queue already existing in the system, associating it to the client. More...
 
MidiQueueuseQueue (MidiQueue *queue)
 Associate an existing MidiQueue instance to the client. More...
 
void portAttach (MidiPort *port)
 Attach a MidiPort instance to this client. More...
 
void portDetach (MidiPort *port)
 Detach a MidiPort instance from this client. More...
 
void detachAllPorts ()
 Detach all the ports belonging to this client.
 
void addEventFilter (int evtype)
 Add an event filter to the client. More...
 
void output (SequencerEvent *ev, bool async=false, int timeout=-1)
 Output an event using the library output buffer. More...
 
void outputDirect (SequencerEvent *ev, bool async=false, int timeout=-1)
 Output an event directly to the sequencer. More...
 
void outputBuffer (SequencerEvent *ev)
 Output an event using the library output buffer, without draining the buffer. More...
 
void drainOutput (bool async=false, int timeout=-1)
 Drain the library output buffer. More...
 
void synchronizeOutput ()
 Wait until all sent events are processed. More...
 
int getClientId ()
 Gets the client ID. More...
 
snd_seq_type_t getSequencerType ()
 Returns the type snd_seq_type_t of the given sequencer handle. More...
 
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. More...
 
void setOutputBufferSize (size_t newSize)
 Sets the size of the library output buffer for the ALSA client. More...
 
size_t getInputBufferSize ()
 Gets the size of the library input buffer for the ALSA client. More...
 
void setInputBufferSize (size_t newSize)
 Sets the size of the library input buffer for the ALSA client. More...
 
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. More...
 
QString getClientName ()
 Gets the client's public name. More...
 
QString getClientName (const int clientId)
 Gets the public name corresponding to the given Client ID. More...
 
void setClientName (QString const &newName)
 Changes the public name of the ALSA sequencer client. More...
 
bool getBroadcastFilter ()
 Gets the broadcast filter usage of the client. More...
 
void setBroadcastFilter (bool newValue)
 Sets the broadcast filter usage of the client. More...
 
bool getErrorBounce ()
 Get the error-bounce usage of the client. More...
 
void setErrorBounce (bool newValue)
 Sets the error-bounce usage of the client. More...
 
ClientInfogetThisClientInfo ()
 Gets the ClientInfo object holding data about this client. More...
 
void setThisClientInfo (const ClientInfo &val)
 Sets the data supplied by the ClientInfo object into the ALSA sequencer client. More...
 
MidiPortList getMidiPorts () const
 Gets the list of MidiPort instances belonging to this client. More...
 
ClientInfoList getAvailableClients ()
 Gets the list of clients from the ALSA sequencer. More...
 
PortInfoList getAvailableInputs ()
 Gets the available user input ports in the system. More...
 
PortInfoList getAvailableOutputs ()
 Gets the available user output ports in the system. More...
 
SystemInfogetSystemInfo ()
 Gets a SystemInfo instance with the updated state of the system. More...
 
QList< int > getAvailableQueues ()
 Get a list of the existing queues. More...
 
PoolInfogetPoolInfo ()
 Gets a PoolInfo instance with an updated state of the client memory pool. More...
 
void setPoolInfo (const PoolInfo &info)
 Applies (updates) the client's PoolInfo data into the system. More...
 
void setPoolInput (int size)
 Sets the size of the client's input pool. More...
 
void setPoolOutput (int size)
 Sets the size of the client's output pool. More...
 
void setPoolOutputRoom (int size)
 Sets the room size of the client's output pool. More...
 
void resetPoolInput ()
 Resets the client input pool. More...
 
void resetPoolOutput ()
 Resets the client output pool. More...
 
void dropInput ()
 Clears the client's input buffer and and remove events in sequencer queue. More...
 
void dropInputBuffer ()
 Remove all events on user-space input buffer. More...
 
void dropOutput ()
 Clears the client's output buffer and and remove events in sequencer queue. More...
 
void dropOutputBuffer ()
 Removes all events on the library output buffer. More...
 
void removeEvents (const RemoveEvents *spec)
 Removes events on input/output buffers and pools. More...
 
SequencerEventextractOutput ()
 Extracts (and removes) the first event in the output buffer. More...
 
int outputPending ()
 Returns the size of pending events on the output buffer. More...
 
int inputPending (bool fetch)
 Gets the size of the events on the input buffer. More...
 
int getQueueId (const QString &name)
 Gets the queue's numeric identifier corresponding to the provided name. More...
 
void addListener (QObject *listener)
 Adds a QObject to the listeners list. More...
 
void removeListener (QObject *listener)
 Removes a QObject listener from the listeners list. More...
 
void setEventsEnabled (const bool bEnabled)
 Enables the notification of received SequencerEvent instances to the listeners registered with addListener() More...
 
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. More...
 
void setRealTimeInput (bool enabled)
 Enables real-time priority for the MIDI input thread. More...
 
bool realTimeInputEnabled ()
 Return the real-time priority setting for the MIDI input thread. More...
 

Protected Member Functions

void doEvents ()
 Dispatch the events received from the Sequencer. More...
 
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. More...
 
const char * _getDeviceName ()
 Gets the internal sequencer device name. More...
 
int getPollDescriptorsCount (short events)
 Returns the number of poll descriptors. More...
 
int pollDescriptors (struct pollfd *pfds, unsigned int space, short events)
 Get poll descriptors. More...
 
unsigned short pollDescriptorsRevents (struct pollfd *pfds, unsigned int nfds)
 Gets the number of returned events from poll descriptors. More...
 
void _setClientName (const char *name)
 Sets the client name. More...
 
int createSimplePort (const char *name, unsigned int caps, unsigned int type)
 Create an ALSA sequencer port, without using MidiPort. More...
 
void deleteSimplePort (int port)
 Remove an ALSA sequencer port. More...
 
void connectFrom (int myport, int client, int port)
 Subscribe one port from another arbitrary sequencer client:port. More...
 
void connectTo (int myport, int client, int port)
 Subscribe one port to another arbitrary sequencer client:port. More...
 
void disconnectFrom (int myport, int client, int port)
 Unsubscribe one port from another arbitrary sequencer client:port. More...
 
void disconnectTo (int myport, int client, int port)
 Unsubscribe one port to another arbitrary sequencer client:port. More...
 

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()

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
parentThe optional parent object
Returns
a MidiClient instance

Definition at line 366 of file alsaclient.cpp.

◆ ~MidiClient()

~MidiClient ( )
virtual

Destructor.

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

Definition at line 384 of file alsaclient.cpp.

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

Member Function Documentation

◆ _getDeviceName()

const char * _getDeviceName ( )
protected

Gets the internal sequencer device name.

Returns
The device name.

Definition at line 1621 of file alsaclient.cpp.

◆ _setClientName()

void _setClientName ( const char *  name)
protected

Sets the client name.

Parameters
nameThe new client name.

Definition at line 1631 of file alsaclient.cpp.

References CHECK_WARNING.

◆ addEventFilter()

void addEventFilter ( int  evtype)

Add an event filter to the client.

Parameters
evtypeAn event filter to be added.

Definition at line 982 of file alsaclient.cpp.

◆ addListener()

void addListener ( QObject listener)

Adds a QObject to the listeners list.

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

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

Definition at line 1342 of file alsaclient.cpp.

◆ close()

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 502 of file alsaclient.cpp.

References CHECK_WARNING, and MidiClient::stopSequencerInput().

Referenced by MidiClient::~MidiClient().

◆ connectFrom()

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

Subscribe one port from another arbitrary sequencer client:port.

Parameters
myportThe number of the internal port.
clientThe external client's identifier.
portThe external port's identifier.

Definition at line 1669 of file alsaclient.cpp.

References CHECK_WARNING.

◆ connectTo()

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

Subscribe one port to another arbitrary sequencer client:port.

Parameters
myportThe number of the internal port.
clientThe external client's identifier.
portThe external port's identifier.

Definition at line 1681 of file alsaclient.cpp.

References CHECK_WARNING.

◆ createPort()

MidiPort * createPort ( )

Create and attach a new MidiPort instance to this client.

Returns
The pointer to the new MidiPort instance.

Definition at line 915 of file alsaclient.cpp.

References MidiPort::attach().

◆ createQueue() [1/2]

MidiQueue * createQueue ( )

Create and return a new MidiQueue associated to this client.

Returns
A new MidiQueue instance.

Definition at line 1162 of file alsaclient.cpp.

Referenced by MidiClient::getQueue().

◆ createQueue() [2/2]

MidiQueue * createQueue ( QString const &  queueName)

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

Parameters
queueNameThe name for the new queue.
Returns
A new MidiQueue instance.

Definition at line 1178 of file alsaclient.cpp.

◆ createSimplePort()

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

Create an ALSA sequencer port, without using MidiPort.

Parameters
nameThe name of the new port.
capsThe new port capabilities.
typeThe type of the new port.
Returns
The port numeric identifier.

Definition at line 1644 of file alsaclient.cpp.

References CHECK_WARNING.

◆ deleteSimplePort()

void deleteSimplePort ( int  port)
protected

Remove an ALSA sequencer port.

Parameters
portThe numeric identifier of the port.

Definition at line 1657 of file alsaclient.cpp.

References CHECK_WARNING.

◆ disconnectFrom()

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

Unsubscribe one port from another arbitrary sequencer client:port.

Parameters
myportThe number of the internal port.
clientThe external client's identifier.
portThe external port's identifier.

Definition at line 1693 of file alsaclient.cpp.

References CHECK_WARNING.

◆ disconnectTo()

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

Unsubscribe one port to another arbitrary sequencer client:port.

Parameters
myportThe number of the internal port.
clientThe external client's identifier.
portThe external port's identifier.

Definition at line 1705 of file alsaclient.cpp.

References CHECK_WARNING.

◆ doEvents()

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 638 of file alsaclient.cpp.

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

◆ drainOutput()

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
asyncUse asynchronous mode. If false, this call will block until the buffer can be flushed.
timeoutThe maximum time to wait in synchronous mode.

Definition at line 1115 of file alsaclient.cpp.

References CHECK_WARNING.

◆ dropInput()

void dropInput ( )

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

See also
resetPoolInput()

Definition at line 1460 of file alsaclient.cpp.

References CHECK_WARNING.

◆ dropInputBuffer()

void dropInputBuffer ( )

Remove all events on user-space input buffer.

See also
dropInput()

Definition at line 1470 of file alsaclient.cpp.

References CHECK_WARNING.

◆ dropOutput()

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 1483 of file alsaclient.cpp.

References CHECK_WARNING.

◆ dropOutputBuffer()

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 1496 of file alsaclient.cpp.

References CHECK_WARNING.

◆ extractOutput()

SequencerEvent * extractOutput ( )

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

Returns
The extracted event.

Definition at line 1518 of file alsaclient.cpp.

References CHECK_WARNING.

◆ filterPorts()

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
filterA bitmap of capabilities.
Returns
A filtered list of the available ports in the system.

Definition at line 1270 of file alsaclient.cpp.

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

Referenced by MidiClient::updateAvailablePorts().

◆ getAvailableClients()

ClientInfoList getAvailableClients ( )

Gets the list of clients from the ALSA sequencer.

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

Definition at line 814 of file alsaclient.cpp.

References MidiClient::readClients().

◆ getAvailableInputs()

PortInfoList getAvailableInputs ( )

Gets the available user input ports in the system.

Returns
The list of available input ports.

Definition at line 1316 of file alsaclient.cpp.

References MidiClient::updateAvailablePorts().

◆ getAvailableOutputs()

PortInfoList getAvailableOutputs ( )

Gets the available user output ports in the system.

Returns
The list of available output ports.

Definition at line 1328 of file alsaclient.cpp.

References MidiClient::updateAvailablePorts().

◆ getAvailableQueues()

QList< int > getAvailableQueues ( )

Get a list of the existing queues.

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

Definition at line 1246 of file alsaclient.cpp.

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

◆ getBroadcastFilter()

bool getBroadcastFilter ( )

Gets the broadcast filter usage of the client.

Returns
The broadcast filter.

Definition at line 993 of file alsaclient.cpp.

References ClientInfo::getBroadcastFilter().

◆ getClientId()

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 602 of file alsaclient.cpp.

References CHECK_WARNING.

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

◆ getClientName() [1/2]

QString getClientName ( )

Gets the client's public name.

Returns
The client's name

Definition at line 863 of file alsaclient.cpp.

References ClientInfo::getName().

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

◆ getClientName() [2/2]

QString getClientName ( const int  clientId)

Gets the public name corresponding to the given Client ID.

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

Definition at line 874 of file alsaclient.cpp.

References MidiClient::readClients().

◆ getErrorBounce()

bool getErrorBounce ( )

Get the error-bounce usage of the client.

Returns
The error-bounce usage.

Definition at line 1016 of file alsaclient.cpp.

References ClientInfo::getErrorBounce().

◆ getInputBufferSize()

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 550 of file alsaclient.cpp.

Referenced by MidiClient::setInputBufferSize().

◆ getMidiPorts()

MidiPortList getMidiPorts ( ) const

Gets the list of MidiPort instances belonging to this client.

Returns
The list of MidiPort instances.

Definition at line 905 of file alsaclient.cpp.

◆ getOutputBufferSize()

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 520 of file alsaclient.cpp.

Referenced by MidiClient::setOutputBufferSize().

◆ getPollDescriptorsCount()

int getPollDescriptorsCount ( short  events)
protected

Returns the number of poll descriptors.

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

Definition at line 1575 of file alsaclient.cpp.

◆ getPoolInfo()

PoolInfo & getPoolInfo ( )

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

Returns
The updated memory pool state.

Definition at line 1388 of file alsaclient.cpp.

◆ getQueue()

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 1149 of file alsaclient.cpp.

References MidiClient::createQueue().

Referenced by SequencerOutputThread::SequencerOutputThread().

◆ getQueueId()

int getQueueId ( const QString &  name)

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

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

Definition at line 1564 of file alsaclient.cpp.

Referenced by MidiClient::useQueue().

◆ getSequencerType()

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 612 of file alsaclient.cpp.

◆ getSystemInfo()

SystemInfo & getSystemInfo ( )

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

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

Definition at line 1377 of file alsaclient.cpp.

Referenced by MidiClient::getAvailableQueues().

◆ getThisClientInfo()

ClientInfo & getThisClientInfo ( )

Gets the ClientInfo object holding data about this client.

Returns
the ClientInfo object representing this client.

Definition at line 827 of file alsaclient.cpp.

◆ inputPending()

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
fetchCheck and fetch the sequencer input pool.
Returns
The size in bytes of the remaining input events on the buffer.

Definition at line 1552 of file alsaclient.cpp.

◆ open() [1/2]

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
deviceNamethe 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.
openModethe 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
blockModeopen in blocking mode, default value = false.
Examples:
sysinfo.cpp.

Definition at line 445 of file alsaclient.cpp.

References CHECK_ERROR, and CHECK_WARNING.

◆ open() [2/2]

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
confa configuration object pointer.
deviceNamethe 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.
openModethe 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
blockModeopen in blocking mode, default value = false.

Definition at line 478 of file alsaclient.cpp.

References CHECK_ERROR, and CHECK_WARNING.

◆ output()

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
evThe event to be sent.
asyncUse asynchronous mode. If false, this call will block until the event can be delivered.
timeoutThe maximum time to wait in synchronous mode.

Definition at line 1045 of file alsaclient.cpp.

References CHECK_WARNING, and SequencerEvent::getHandle().

◆ outputBuffer()

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
evThe event to be sent.

Definition at line 1099 of file alsaclient.cpp.

References CHECK_WARNING, and SequencerEvent::getHandle().

◆ outputDirect()

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
evThe event to be sent.
asyncUse asynchronous mode. If false, this call will block until the event is delivered to the sequencer.
timeoutThe maximum time to wait in synchronous mode.

Definition at line 1073 of file alsaclient.cpp.

References CHECK_WARNING, and SequencerEvent::getHandle().

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

◆ outputPending()

int outputPending ( )

Returns the size of pending events on the output buffer.

Returns
The size of pending events.

Definition at line 1533 of file alsaclient.cpp.

◆ parseAddress()

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
straddrsource text address representation
addrreturned ALSA address record
Returns
true if the text address was successfully parsed
Since
0.3.1

Definition at line 1722 of file alsaclient.cpp.

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

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

◆ pollDescriptors()

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
pfdsArray of poll descriptors
spaceSpace in the poll descriptor array
eventsPolling events to be checked (POLLIN and POLLOUT)
Returns
Count of filled descriptors

Definition at line 1594 of file alsaclient.cpp.

◆ pollDescriptorsRevents()

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

Gets the number of returned events from poll descriptors.

Parameters
pfdsArray of poll descriptors.
nfdsCount of poll descriptors.
Returns
Number of returned events.

Definition at line 1607 of file alsaclient.cpp.

References CHECK_WARNING.

◆ portAttach()

void portAttach ( MidiPort port)

Attach a MidiPort instance to this client.

Parameters
portThe MidiPort to be attached

Definition at line 927 of file alsaclient.cpp.

References CHECK_ERROR.

Referenced by MidiPort::attach().

◆ portDetach()

void portDetach ( MidiPort port)

Detach a MidiPort instance from this client.

Parameters
portThe MidiPort to be detached

Definition at line 940 of file alsaclient.cpp.

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

Referenced by MidiPort::detach().

◆ realTimeInputEnabled()

bool realTimeInputEnabled ( )

Return the real-time priority setting for the MIDI input thread.

Returns
true if the real-time priority is enabled
Since
0.5.0

Definition at line 417 of file alsaclient.cpp.

◆ removeEvents()

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
specA RemoveEvents instance specifying the removal condition.

Definition at line 1508 of file alsaclient.cpp.

References CHECK_WARNING.

◆ removeListener()

void removeListener ( QObject listener)

Removes a QObject listener from the listeners list.

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

Definition at line 1353 of file alsaclient.cpp.

◆ resetPoolInput()

void resetPoolInput ( )

Resets the client input pool.

See also
dropInput()

Definition at line 1410 of file alsaclient.cpp.

References CHECK_WARNING.

◆ resetPoolOutput()

void resetPoolOutput ( )

Resets the client output pool.

See also
dropOutput()

Definition at line 1420 of file alsaclient.cpp.

References CHECK_WARNING.

◆ setBlockMode()

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
newValuethe blocking mode

Definition at line 581 of file alsaclient.cpp.

References CHECK_WARNING.

◆ setBroadcastFilter()

void setBroadcastFilter ( bool  newValue)

Sets the broadcast filter usage of the client.

Parameters
newValueThe broadcast filter.

Definition at line 1004 of file alsaclient.cpp.

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

◆ setClientName()

void setClientName ( QString const &  newName)

Changes the public name of the ALSA sequencer client.

Parameters
newNameA new public name
Examples:
sysinfo.cpp.

Definition at line 892 of file alsaclient.cpp.

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

◆ setErrorBounce()

void setErrorBounce ( bool  newValue)

Sets the error-bounce usage of the client.

Parameters
newValueThe error-bounce usage.

Definition at line 1027 of file alsaclient.cpp.

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

◆ setEventsEnabled()

void setEventsEnabled ( const bool  bEnabled)

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

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

Definition at line 1365 of file alsaclient.cpp.

◆ setInputBufferSize()

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
newSizethe size of the library input buffer

Definition at line 564 of file alsaclient.cpp.

References CHECK_WARNING, and MidiClient::getInputBufferSize().

◆ setOutputBufferSize()

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
newSizethe size of the library output buffer

Definition at line 534 of file alsaclient.cpp.

References CHECK_WARNING, and MidiClient::getOutputBufferSize().

◆ setPoolInfo()

void setPoolInfo ( const PoolInfo info)

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

Parameters
infoThe PoolInfo reference to be applied to the client.

Definition at line 1399 of file alsaclient.cpp.

References CHECK_WARNING.

◆ setPoolInput()

void setPoolInput ( int  size)

Sets the size of the client's input pool.

Parameters
sizeThe new size

Definition at line 1430 of file alsaclient.cpp.

References CHECK_WARNING.

◆ setPoolOutput()

void setPoolOutput ( int  size)

Sets the size of the client's output pool.

Parameters
sizeThe new size

Definition at line 1440 of file alsaclient.cpp.

References CHECK_WARNING.

◆ setPoolOutputRoom()

void setPoolOutputRoom ( int  size)

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

Parameters
sizeThe new size

Definition at line 1450 of file alsaclient.cpp.

References CHECK_WARNING.

◆ setRealTimeInput()

void setRealTimeInput ( bool  enable)

Enables real-time priority for the MIDI input thread.

The system needs either RLIMIT_RTPRIO or RealtimeKit. First RLIMIT_RTPRIO is tried, and if this method fails, RealtimeKit is used.

Parameters
enablereal-time priority enabled
Since
0.5.0

Definition at line 404 of file alsaclient.cpp.

◆ setThisClientInfo()

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
vala ClientInfo object reference

Definition at line 841 of file alsaclient.cpp.

◆ synchronizeOutput()

void synchronizeOutput ( )

Wait until all sent events are processed.

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

Definition at line 1138 of file alsaclient.cpp.

◆ useQueue() [1/3]

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_idAn existing queue identifier.
Returns
A new MidiQueue instance.

Definition at line 1195 of file alsaclient.cpp.

◆ useQueue() [2/3]

MidiQueue * useQueue ( const QString &  name)

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

Parameters
nameAn existing queue name.
Returns
A new MidiQueue instance.

Definition at line 1212 of file alsaclient.cpp.

References MidiClient::getQueueId().

◆ useQueue() [3/3]

MidiQueue * useQueue ( MidiQueue queue)

Associate an existing MidiQueue instance to the client.

Parameters
queueAn existing MidiQueue.
Returns
The provided MidiQueue instance.

Definition at line 1231 of file alsaclient.cpp.


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