drumstick 2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.
|
ALSA clients are any entities using ALSA sequencer services. More...
Classes | |
class | ClientInfo |
Client information. More... | |
class | SystemInfo |
System information. More... | |
class | PoolInfo |
Sequencer Pool information. More... | |
class | SequencerEventHandler |
Sequencer events handler. More... | |
class | MidiClient |
Client management. More... | |
class | MidiClient::SequencerInputThread |
This class manages event input from the ALSA sequencer. More... | |
Typedefs | |
typedef QList< ClientInfo > | ClientInfoList |
List of sequencer client information. | |
Functions | |
QString | getRuntimeALSADriverVersion () |
Gets the runtime ALSA drivers version string. More... | |
int | getRuntimeALSADriverNumber () |
Gets the runtime ALSA drivers version number. More... | |
QString | getCompiledALSALibraryVersion () |
ALSA library version at build time. More... | |
QString | getDrumstickLibraryVersion () |
getDrumstickLibraryVersion provides the Drumstick version as an edited QString More... | |
MidiClient (QObject *parent=nullptr) | |
Constructor. More... | |
virtual | ~MidiClient () |
Destructor. More... | |
snd_seq_t * | getHandle () |
Returns the sequencer handler managed by ALSA. More... | |
bool | isOpened () |
Returns true if the sequencer is opened. More... | |
QString | getDeviceName () |
Returns the name of the sequencer device. More... | |
int | getOpenMode () |
Returns the last open mode used in open() More... | |
bool | getBlockMode () |
Returns the last block mode used in open() More... | |
bool | getEventsEnabled () const |
Returns true if the events mode of delivery has been enabled. More... | |
void | setHandler (SequencerEventHandler *handler) |
Sets a sequencer event handler enabling the callback delivery mode. 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... | |
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... | |
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... | |
void | setBlockMode (bool newValue) |
Change the blocking mode of the client. 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... | |
void | doEvents () |
Dispatch the events received from the Sequencer. More... | |
void | startSequencerInput () |
Starts reading events from the ALSA sequencer. | |
void | stopSequencerInput () |
Stops reading events from the ALSA sequencer. | |
void | readClients () |
Reads the ALSA sequencer's clients list. | |
void | freeClients () |
Releases the list of ALSA sequencer's clients. | |
ClientInfoList | getAvailableClients () |
Gets the list of clients from the ALSA sequencer. More... | |
ClientInfo & | getThisClientInfo () |
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... | |
void | applyClientInfo () |
This internal method applies the ClientInfo data to the ALSA sequencer client. | |
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... | |
MidiPortList | getMidiPorts () const |
Gets the list of MidiPort instances belonging to this client. More... | |
MidiPort * | createPort () |
Create and attach a new MidiPort instance to this 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... | |
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... | |
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... | |
MidiQueue * | getQueue () |
Get the MidiQueue instance associated to this client. More... | |
MidiQueue * | createQueue () |
Create and return a new MidiQueue associated to this client. More... | |
MidiQueue * | createQueue (QString const &name) |
Create and return a new MidiQueue with the given name, associated to this client. More... | |
MidiQueue * | useQueue (int queue_id) |
Create a new MidiQueue instance using a queue already existing in the system, associating it to the client. More... | |
MidiQueue * | useQueue (const QString &name) |
Create a new MidiQueue instance using a queue already existing in the system, associating it to the client. More... | |
MidiQueue * | useQueue (MidiQueue *queue) |
Associate an existing MidiQueue instance to the client. More... | |
QList< int > | getAvailableQueues () |
Get a list of the existing queues. More... | |
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... | |
void | updateAvailablePorts () |
Update the internal lists of user ports. | |
PortInfoList | getAvailableInputs () |
Gets the available user input ports in the system. More... | |
PortInfoList | getAvailableOutputs () |
Gets the available user output ports in the system. 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... | |
SystemInfo & | getSystemInfo () |
Gets a SystemInfo instance with the updated state of the system. More... | |
PoolInfo & | getPoolInfo () |
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 | resetPoolInput () |
Resets the client input pool. More... | |
void | resetPoolOutput () |
Resets the client output pool. 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 | 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... | |
SequencerEvent * | extractOutput () |
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... | |
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... | |
const char * | _getDeviceName () |
Gets the internal sequencer device name. 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... | |
bool | parseAddress (const QString &straddr, snd_seq_addr &result) |
Parse a text address representation, returning an ALSA address record. More... | |
bool | stopped () |
Returns true or false depending on the input thread state. More... | |
void | stop () |
Stops the input thread. | |
void | run () override |
Main input thread process loop. | |
ClientInfo () | |
Default constructor. | |
ClientInfo (const ClientInfo &other) | |
Copy constructor. More... | |
ClientInfo (snd_seq_client_info_t *other) | |
Copy constructor. More... | |
ClientInfo (MidiClient *seq, int id) | |
Constructor. More... | |
virtual | ~ClientInfo () |
Destructor. | |
ClientInfo * | clone () |
Clone the client info object. More... | |
ClientInfo & | operator= (const ClientInfo &other) |
Assignment operator. More... | |
int | getClientId () |
Gets the client's numeric identifier. More... | |
snd_seq_client_type_t | getClientType () |
Gets the client's type. More... | |
QString | getName () |
Gets the client's name. More... | |
bool | getBroadcastFilter () |
Gets the client's broadcast filter. More... | |
bool | getErrorBounce () |
Gets the client's error bounce. More... | |
Q_DECL_DEPRECATED const unsigned char * | getEventFilter () |
Gets the client's event filter. More... | |
int | getNumPorts () |
Gets the client's port count. More... | |
int | getEventLost () |
Gets the number of lost events. More... | |
void | setClient (int client) |
Sets the client identifier number. More... | |
void | setName (QString name) |
Sets the client name. More... | |
void | setBroadcastFilter (bool val) |
Sets the broadcast filter. More... | |
void | setErrorBounce (bool val) |
Sets the error bounce. More... | |
Q_DECL_DEPRECATED void | setEventFilter (unsigned char *filter) |
Sets the event filter. More... | |
void | readPorts (MidiClient *seq) |
Read the client ports. More... | |
void | freePorts () |
Release the ports list. | |
PortInfoList | getPorts () const |
Gets the ports list. More... | |
int | getSizeOfInfo () const |
Gets the size of the internal object. More... | |
SystemInfo () | |
Default constructor. | |
SystemInfo (const SystemInfo &other) | |
Copy constructor. More... | |
SystemInfo (snd_seq_system_info_t *other) | |
Copy constructor. More... | |
SystemInfo (MidiClient *seq) | |
Constructor. More... | |
virtual | ~SystemInfo () |
Destructor. | |
SystemInfo * | clone () |
Clone the system info object. More... | |
SystemInfo & | operator= (const SystemInfo &other) |
Assignment operator. More... | |
int | getMaxClients () |
Get the system's maximum number of clients. More... | |
int | getMaxPorts () |
Get the system's maximum number of ports. More... | |
int | getMaxQueues () |
Get the system's maximum number of queues. More... | |
int | getMaxChannels () |
Get the system's maximum number of channels. More... | |
int | getCurrentQueues () |
Get the system's current number of queues. More... | |
int | getCurrentClients () |
Get the system's current number of clients. More... | |
int | getSizeOfInfo () const |
Get the system's info object size. More... | |
PoolInfo () | |
Default constructor. | |
PoolInfo (const PoolInfo &other) | |
Copy constructor. More... | |
PoolInfo (snd_seq_client_pool_t *other) | |
Copy constructor. More... | |
PoolInfo (MidiClient *seq) | |
Constructor. More... | |
virtual | ~PoolInfo () |
Destructor. | |
PoolInfo * | clone () |
Clone the pool info obeject. More... | |
PoolInfo & | operator= (const PoolInfo &other) |
Assignment operator. More... | |
int | getClientId () |
Gets the client ID for this object. More... | |
int | getInputFree () |
Gets the available size on input pool. More... | |
int | getInputPool () |
Gets the input pool size. More... | |
int | getOutputFree () |
Gets the available size on output pool. More... | |
int | getOutputPool () |
Gets the output pool size. More... | |
int | getOutputRoom () |
Gets the output room size. More... | |
void | setInputPool (int size) |
Set the input pool size. More... | |
void | setOutputPool (int size) |
Sets the output pool size. More... | |
void | setOutputRoom (int size) |
Sets the output room size. More... | |
int | getSizeOfInfo () const |
Gets the size of the client pool object. More... | |
ALSA clients are any entities using ALSA sequencer services.
A client may be an application or a device driver for an external MIDI port, like USB MIDI devices or the MIDI/game ports of some sound cards. This library allows to easily create applications managing ALSA clients.
ALSA clients are also file descriptors representing a sequencer device, that must be opened before reading or writing MIDI events. When the client is opened, it is given some handle and a number identifying it to other clients in the system. You can also provide a name for it.
Each ALSA sequencer client can have several ports attached. The ports can be readable or writable, and can be subscribed in pairs: one readable port to one writable port. The subscriptions can be made and queried by external applications, like "aconnect" or "qjackctl".
SystemInfo is an auxiliary class to query several system capabilities.
The PoolInfo class represents a container to query and change some values for the kernel memory pool assigned to an ALSA client.
The ClientInfo class is another container to query and change properties of the MidiClient itself.
The SequencerEventHandler abstract class is used to define an interface that other class can implement to receive sequencer events. It is one of the three methods of delivering input events offered by the library.
MidiClient uses a separate thread to receive events from the ALSA sequencer. The input thread can be started and stopped using the methods MidiClient::startSequencerInput() and MidiClient::stopSequencerInput(). It is necessary to have this thread in mind when using this library to read events. There are three delivering methods of input events:
The selected method depends only on your requirements and your preferences.
Whichever method you select, it excludes the other methods for the same program. A callback takes precedence over the others. If it is not set, then the events are sent if MidiClient::setEventsEnabled() is called. If neither a callback handler is set nor events are enabled, then the signal is emitted. In any case, the event pointer must be deleted by the receiver method.
The methods to send a single event to the ALSA sequencer are:
The two first methods usually require a call to MidiClient::drainOutput() to flush the ALSA library output buffer. The third one bypasses the buffer, and doesn't require the call to MidiClient::drainOutput(). Note that the buffer can be automatically drained by the first method when it becomes full.
After being dispatched to the ALSA Sequencer, the events can be scheduled at some time in the future, or immediately. This depends on the following methods of the SequencerEvent class:
When you need to schedule a lot of events, for instance reproducing a Standard MIDI File (SMF) or a MIDI sequence, you may want to use the abstract class SequencerOutputThread.
There are two memory issues: the memory pool belongs to the kernel sequencer, and can be managed by the class PoolInfo and the methods MidiClient::getPoolInfo() and MidiClient::setPoolInfo(). The library buffer can be controlled using the methods MidiClient::getOutputBufferSize() and MidiClient::setOutputBufferSize() as well as MidiClient::getInputBufferSize() and MidiClient::setInputBufferSize().
|
protected |
Gets the internal sequencer device name.
Definition at line 1570 of file alsaclient.cpp.
|
protected |
Sets the client name.
name | The new client name. |
Definition at line 1580 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void addEventFilter | ( | int | evtype | ) |
Add an event filter to the client.
evtype | An event filter to be added. |
Definition at line 933 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.
listener | A QObject listener to be notified of received events. |
Definition at line 1291 of file alsaclient.cpp.
ClientInfo | ( | const ClientInfo & | other | ) |
Copy constructor.
other | Another ClientInfo reference to be copied |
Definition at line 1836 of file alsaclient.cpp.
ClientInfo | ( | MidiClient * | seq, |
int | id | ||
) |
Constructor.
seq | A MidiClient object |
id | A numeric client id |
Definition at line 1858 of file alsaclient.cpp.
References MidiClient::getHandle().
|
explicit |
Copy constructor.
other | An existing ALSA client info object |
Definition at line 1847 of file alsaclient.cpp.
ClientInfo * clone | ( | ) |
Clone the client info object.
Definition at line 1878 of file alsaclient.cpp.
SystemInfo * clone | ( | ) |
Clone the system info object.
Definition at line 2172 of file alsaclient.cpp.
PoolInfo * clone | ( | ) |
Clone the pool info obeject.
Definition at line 2305 of file alsaclient.cpp.
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 452 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING, and MidiClient::stopSequencerInput().
Referenced by MidiClient::~MidiClient().
|
protected |
Subscribe one port from another arbitrary sequencer client:port.
myport | The number of the internal port. |
client | The external client's identifier. |
port | The external port's identifier. |
Definition at line 1618 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
|
protected |
Subscribe one port to another arbitrary sequencer client:port.
myport | The number of the internal port. |
client | The external client's identifier. |
port | The external port's identifier. |
Definition at line 1630 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
MidiPort * createPort | ( | ) |
Create and attach a new MidiPort instance to this client.
Definition at line 865 of file alsaclient.cpp.
References MidiPort::attach().
MidiQueue * createQueue | ( | ) |
Create and return a new MidiQueue associated to this client.
Definition at line 1111 of file alsaclient.cpp.
Referenced by MidiClient::getQueue().
MidiQueue * createQueue | ( | QString const & | queueName | ) |
Create and return a new MidiQueue with the given name, associated to this client.
queueName | The name for the new queue. |
Definition at line 1127 of file alsaclient.cpp.
|
protected |
Create an ALSA sequencer port, without using MidiPort.
name | The name of the new port. |
caps | The new port capabilities. |
type | The type of the new port. |
Definition at line 1593 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
|
protected |
Remove an ALSA sequencer port.
port | The numeric identifier of the port. |
Definition at line 1606 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
|
protected |
Unsubscribe one port from another arbitrary sequencer client:port.
myport | The number of the internal port. |
client | The external client's identifier. |
port | The external port's identifier. |
Definition at line 1642 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
|
protected |
Unsubscribe one port to another arbitrary sequencer client:port.
myport | The number of the internal port. |
client | The external client's identifier. |
port | The external port's identifier. |
Definition at line 1654 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
|
protected |
Dispatch the events received from the Sequencer.
There are three methods of events delivering:
Definition at line 588 of file alsaclient.cpp.
References MidiClient::eventReceived().
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.
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 1065 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void dropInput | ( | ) |
Clears the client's input buffer and and remove events in sequencer queue.
Definition at line 1409 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void dropInputBuffer | ( | ) |
Remove all events on user-space input buffer.
Definition at line 1419 of file alsaclient.cpp.
References DRUMSTICK_ALSA_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.
Definition at line 1432 of file alsaclient.cpp.
References DRUMSTICK_ALSA_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.
Definition at line 1445 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
SequencerEvent * extractOutput | ( | ) |
Extracts (and removes) the first event in the output buffer.
Definition at line 1467 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
|
protected |
Gets a list of the available user ports in the system, filtered by the given bitmap of desired capabilities.
filter | A bitmap of capabilities. |
Definition at line 1219 of file alsaclient.cpp.
References PortInfo::getCapability(), ClientInfo::getClientId(), ClientInfo::getPorts(), and MidiClient::readClients().
Referenced by MidiClient::updateAvailablePorts().
ClientInfoList getAvailableClients | ( | ) |
Gets the list of clients from the ALSA sequencer.
Definition at line 764 of file alsaclient.cpp.
References MidiClient::readClients().
PortInfoList getAvailableInputs | ( | ) |
Gets the available user input ports in the system.
Definition at line 1265 of file alsaclient.cpp.
References MidiClient::updateAvailablePorts().
PortInfoList getAvailableOutputs | ( | ) |
Gets the available user output ports in the system.
Definition at line 1277 of file alsaclient.cpp.
References MidiClient::updateAvailablePorts().
QList< int > getAvailableQueues | ( | ) |
Get a list of the existing queues.
Definition at line 1195 of file alsaclient.cpp.
References SystemInfo::getMaxQueues(), and MidiClient::getSystemInfo().
bool getBlockMode | ( | ) |
Returns the last block mode used in open()
Definition at line 322 of file alsaclient.cpp.
bool getBroadcastFilter | ( | ) |
Gets the client's broadcast filter.
Definition at line 1933 of file alsaclient.cpp.
bool getBroadcastFilter | ( | ) |
Gets the broadcast filter usage of the client.
Definition at line 944 of file alsaclient.cpp.
int getClientId | ( | ) |
Gets the client's numeric identifier.
Definition at line 1903 of file alsaclient.cpp.
Referenced by MidiClient::filterPorts(), and MidiClient::parseAddress().
int getClientId | ( | ) |
Gets the client ID for this object.
Definition at line 2329 of file alsaclient.cpp.
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.
Definition at line 552 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
Referenced by MidiClient::portDetach(), ClientInfo::readPorts(), and SequencerOutputThread::sendEchoEvent().
QString getClientName | ( | ) |
Gets the client's public name.
Definition at line 813 of file alsaclient.cpp.
Referenced by MidiPort::getReadSubscribers(), and MidiPort::getWriteSubscribers().
QString getClientName | ( | const int | clientId | ) |
Gets the public name corresponding to the given Client ID.
clientId | The ID of any existing sequencer client |
Definition at line 824 of file alsaclient.cpp.
References MidiClient::readClients().
snd_seq_client_type_t getClientType | ( | ) |
Gets the client's type.
Definition at line 1913 of file alsaclient.cpp.
DRUMSTICK_ALSA_EXPORT QString getCompiledALSALibraryVersion | ( | ) |
ALSA library version at build time.
This string corresponds to the compilation library, which may be different to the runtime library.
Definition at line 2520 of file alsaclient.cpp.
int getCurrentClients | ( | ) |
Get the system's current number of clients.
Definition at line 2240 of file alsaclient.cpp.
int getCurrentQueues | ( | ) |
Get the system's current number of queues.
Definition at line 2231 of file alsaclient.cpp.
QString getDeviceName | ( | ) |
Returns the name of the sequencer device.
Definition at line 304 of file alsaclient.cpp.
DRUMSTICK_ALSA_EXPORT QString getDrumstickLibraryVersion | ( | ) |
getDrumstickLibraryVersion provides the Drumstick version as an edited QString
Definition at line 2529 of file alsaclient.cpp.
bool getErrorBounce | ( | ) |
Gets the client's error bounce.
Definition at line 1943 of file alsaclient.cpp.
bool getErrorBounce | ( | ) |
Get the error-bounce usage of the client.
Definition at line 967 of file alsaclient.cpp.
|
protected |
Gets the client's event filter.
Definition at line 1954 of file alsaclient.cpp.
int getEventLost | ( | ) |
Gets the number of lost events.
Definition at line 1974 of file alsaclient.cpp.
bool getEventsEnabled | ( | ) | const |
Returns true if the events mode of delivery has been enabled.
Definition at line 331 of file alsaclient.cpp.
snd_seq_t * getHandle | ( | ) |
Returns the sequencer handler managed by ALSA.
Definition at line 286 of file alsaclient.cpp.
Referenced by MidiPort::applyPortInfo(), MidiQueue::clear(), ClientInfo::ClientInfo(), MidiQueue::continueRunning(), SequencerOutputThread::drainOutput(), MidiQueue::getInfo(), MidiQueue::getStatus(), MidiQueue::getTempo(), MidiQueue::getTimer(), MidiQueue::getUsage(), MidiQueue::MidiQueue(), PoolInfo::PoolInfo(), PortInfo::PortInfo(), ClientInfo::readPorts(), PortInfo::readSubscribers(), SequencerOutputThread::run(), SequencerOutputThread::sendSongEvent(), MidiQueue::setInfo(), MidiQueue::setTempo(), MidiQueue::setTimer(), MidiQueue::setUsage(), MidiQueue::start(), MidiQueue::stop(), Subscription::subscribe(), MidiPort::subscribeFrom(), MidiPort::subscribeTo(), Subscription::Subscription(), SystemInfo::SystemInfo(), Subscription::unsubscribe(), MidiPort::unsubscribeFrom(), MidiPort::unsubscribeTo(), and MidiQueue::~MidiQueue().
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.
Definition at line 500 of file alsaclient.cpp.
Referenced by MidiClient::setInputBufferSize().
int getInputFree | ( | ) |
Gets the available size on input pool.
Definition at line 2339 of file alsaclient.cpp.
int getInputPool | ( | ) |
Gets the input pool size.
Definition at line 2349 of file alsaclient.cpp.
int getMaxChannels | ( | ) |
Get the system's maximum number of channels.
Definition at line 2222 of file alsaclient.cpp.
int getMaxClients | ( | ) |
Get the system's maximum number of clients.
Definition at line 2195 of file alsaclient.cpp.
int getMaxPorts | ( | ) |
Get the system's maximum number of ports.
Definition at line 2204 of file alsaclient.cpp.
int getMaxQueues | ( | ) |
Get the system's maximum number of queues.
Definition at line 2213 of file alsaclient.cpp.
Referenced by MidiClient::getAvailableQueues().
MidiPortList getMidiPorts | ( | ) | const |
Gets the list of MidiPort instances belonging to this client.
Definition at line 855 of file alsaclient.cpp.
QString getName | ( | ) |
Gets the client's name.
Definition at line 1923 of file alsaclient.cpp.
Referenced by MidiClient::parseAddress().
int getNumPorts | ( | ) |
Gets the client's port count.
Definition at line 1964 of file alsaclient.cpp.
int getOpenMode | ( | ) |
Returns the last open mode used in open()
Definition at line 313 of file alsaclient.cpp.
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.
Definition at line 470 of file alsaclient.cpp.
Referenced by MidiClient::setOutputBufferSize().
int getOutputFree | ( | ) |
Gets the available size on output pool.
Definition at line 2359 of file alsaclient.cpp.
int getOutputPool | ( | ) |
Gets the output pool size.
Definition at line 2369 of file alsaclient.cpp.
int getOutputRoom | ( | ) |
Gets the output room size.
The output room is the minimum pool size for select/blocking mode.
Definition at line 2380 of file alsaclient.cpp.
|
protected |
Returns the number of poll descriptors.
events | Poll events to be checked (POLLIN and POLLOUT). |
Definition at line 1524 of file alsaclient.cpp.
PoolInfo & getPoolInfo | ( | ) |
Gets a PoolInfo instance with an updated state of the client memory pool.
Definition at line 1337 of file alsaclient.cpp.
PortInfoList getPorts | ( | ) | const |
Gets the ports list.
Definition at line 2062 of file alsaclient.cpp.
Referenced by MidiClient::filterPorts().
MidiQueue * getQueue | ( | ) |
Get the MidiQueue instance associated to this client.
If the client is not associated to a MidiQueue, one is created.
Definition at line 1098 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.
name | The name string to query. |
Definition at line 1513 of file alsaclient.cpp.
Referenced by MidiClient::useQueue().
DRUMSTICK_ALSA_EXPORT int getRuntimeALSADriverNumber | ( | ) |
Gets the runtime ALSA drivers version number.
Definition at line 2493 of file alsaclient.cpp.
References drumstick::ALSA::getRuntimeALSADriverVersion().
DRUMSTICK_ALSA_EXPORT QString getRuntimeALSADriverVersion | ( | ) |
Gets the runtime ALSA drivers version string.
Definition at line 2471 of file alsaclient.cpp.
Referenced by drumstick::ALSA::getRuntimeALSADriverNumber().
snd_seq_type_t getSequencerType | ( | ) |
Returns the type snd_seq_type_t of the given sequencer handle.
Definition at line 562 of file alsaclient.cpp.
int getSizeOfInfo | ( | ) | const |
Gets the size of the internal object.
Definition at line 2073 of file alsaclient.cpp.
int getSizeOfInfo | ( | ) | const |
Get the system's info object size.
Definition at line 2249 of file alsaclient.cpp.
int getSizeOfInfo | ( | ) | const |
Gets the size of the client pool object.
Definition at line 2422 of file alsaclient.cpp.
SystemInfo & getSystemInfo | ( | ) |
Gets a SystemInfo instance with the updated state of the system.
Definition at line 1326 of file alsaclient.cpp.
Referenced by MidiClient::getAvailableQueues().
ClientInfo & getThisClientInfo | ( | ) |
Gets the ClientInfo object holding data about this client.
Definition at line 777 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.
fetch | Check and fetch the sequencer input pool. |
Definition at line 1501 of file alsaclient.cpp.
bool isOpened | ( | ) |
Returns true if the sequencer is opened.
Definition at line 295 of file alsaclient.cpp.
Referenced by MidiPort::applyPortInfo(), Subscription::subscribe(), and Subscription::unsubscribe().
|
explicit |
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.
parent | The optional parent object |
Definition at line 258 of file alsaclient.cpp.
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.
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:
|
blockMode | open in blocking mode, default value = false. |
Definition at line 395 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_ERROR, and DRUMSTICK_ALSA_CHECK_WARNING.
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.
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:
|
blockMode | open in blocking mode, default value = false. |
Definition at line 428 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_ERROR, and DRUMSTICK_ALSA_CHECK_WARNING.
ClientInfo & operator= | ( | const ClientInfo & | other | ) |
Assignment operator.
other | Another ClientInfo object |
Definition at line 1889 of file alsaclient.cpp.
Assignment operator.
other | Another PoolInfo object reference to be copied |
Definition at line 2316 of file alsaclient.cpp.
SystemInfo & operator= | ( | const SystemInfo & | other | ) |
Assignment operator.
other | Another SystemInfo object |
Definition at line 2183 of file alsaclient.cpp.
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.
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 996 of file alsaclient.cpp.
References DRUMSTICK_ALSA_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.
ev | The event to be sent. |
Definition at line 1049 of file alsaclient.cpp.
References DRUMSTICK_ALSA_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.
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 1024 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING, and SequencerEvent::getHandle().
Referenced by MidiQueue::setRealTimePosition(), and MidiQueue::setTickPosition().
int outputPending | ( | ) |
Returns the size of pending events on the output buffer.
Definition at line 1482 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().
straddr | source text address representation |
addr | returned ALSA address record |
Definition at line 1671 of file alsaclient.cpp.
References ClientInfo::getClientId(), ClientInfo::getName(), and MidiClient::readClients().
Referenced by MidiPort::subscribeFrom(), MidiPort::subscribeTo(), MidiPort::unsubscribeFrom(), and MidiPort::unsubscribeTo().
|
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.
pfds | Array of poll descriptors |
space | Space in the poll descriptor array |
events | Polling events to be checked (POLLIN and POLLOUT) |
Definition at line 1543 of file alsaclient.cpp.
|
protected |
Gets the number of returned events from poll descriptors.
pfds | Array of poll descriptors. |
nfds | Count of poll descriptors. |
Definition at line 1556 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
Copy constructor.
other | Another PoolInfo object reference to be copied |
Definition at line 2266 of file alsaclient.cpp.
|
explicit |
Constructor.
seq | A MidiClient object |
Definition at line 2286 of file alsaclient.cpp.
References MidiClient::getHandle().
|
explicit |
Copy constructor.
other | An ALSA pool info object to be copied |
Definition at line 2276 of file alsaclient.cpp.
void portAttach | ( | MidiPort * | port | ) |
Attach a MidiPort instance to this client.
port | The MidiPort to be attached |
Definition at line 877 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_ERROR.
Referenced by MidiPort::attach().
void portDetach | ( | MidiPort * | port | ) |
Detach a MidiPort instance from this client.
port | The MidiPort to be detached |
Definition at line 890 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_ERROR, PortInfo::getClient(), MidiClient::getClientId(), PortInfo::getPort(), MidiPort::getPortInfo(), and MidiPort::setMidiClient().
Referenced by MidiPort::detach().
|
protected |
Read the client ports.
seq | The client instance. |
Definition at line 2035 of file alsaclient.cpp.
References MidiClient::getClientId(), MidiClient::getHandle(), PortInfo::readSubscribers(), PortInfo::setClient(), PortInfo::setClientName(), and PortInfo::setPort().
Referenced by MidiClient::readClients().
bool realTimeInputEnabled | ( | ) |
Return the real-time priority setting for the MIDI input thread.
Definition at line 367 of file alsaclient.cpp.
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.
spec | A RemoveEvents instance specifying the removal condition. |
Definition at line 1457 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void removeListener | ( | QObject * | listener | ) |
Removes a QObject listener from the listeners list.
listener | listener A QObject listener to be removed of received events. |
Definition at line 1302 of file alsaclient.cpp.
void resetPoolInput | ( | ) |
Resets the client input pool.
Definition at line 1359 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void resetPoolOutput | ( | ) |
Resets the client output pool.
Definition at line 1369 of file alsaclient.cpp.
References DRUMSTICK_ALSA_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.
newValue | the blocking mode |
Definition at line 531 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void setBroadcastFilter | ( | bool | newValue | ) |
Sets the broadcast filter usage of the client.
newValue | The broadcast filter. |
Definition at line 955 of file alsaclient.cpp.
References MidiClient::applyClientInfo().
void setBroadcastFilter | ( | bool | val | ) |
Sets the broadcast filter.
val | The broadcast filter. |
Definition at line 2004 of file alsaclient.cpp.
void setClient | ( | int | client | ) |
Sets the client identifier number.
client | The client identifier number. |
Definition at line 1984 of file alsaclient.cpp.
Referenced by MidiClient::readClients().
void setClientName | ( | QString const & | newName | ) |
Changes the public name of the ALSA sequencer client.
newName | A new public name |
Definition at line 842 of file alsaclient.cpp.
References MidiClient::applyClientInfo().
void setErrorBounce | ( | bool | newValue | ) |
Sets the error-bounce usage of the client.
newValue | The error-bounce usage. |
Definition at line 978 of file alsaclient.cpp.
References MidiClient::applyClientInfo().
void setErrorBounce | ( | bool | val | ) |
Sets the error bounce.
val | The error bounce. |
Definition at line 2014 of file alsaclient.cpp.
|
protected |
Sets the event filter.
filter | The event filter. |
Definition at line 2025 of file alsaclient.cpp.
void setEventsEnabled | ( | const bool | bEnabled | ) |
Enables the notification of received SequencerEvent instances to the listeners registered with addListener()
bEnabled | The new state of the events delivering mode. |
Definition at line 1314 of file alsaclient.cpp.
void setHandler | ( | SequencerEventHandler * | handler | ) |
Sets a sequencer event handler enabling the callback delivery mode.
handler | the sequencer event handler |
Definition at line 340 of file alsaclient.cpp.
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.
newSize | the size of the library input buffer |
Definition at line 514 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING, and MidiClient::getInputBufferSize().
void setInputPool | ( | int | size | ) |
Set the input pool size.
size | The input pool size. |
Definition at line 2390 of file alsaclient.cpp.
void setName | ( | QString | name | ) |
Sets the client name.
name | The client name. |
Definition at line 1994 of file alsaclient.cpp.
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.
newSize | the size of the library output buffer |
Definition at line 484 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING, and MidiClient::getOutputBufferSize().
void setOutputPool | ( | int | size | ) |
Sets the output pool size.
size | The output pool size. |
Definition at line 2400 of file alsaclient.cpp.
void setOutputRoom | ( | int | size | ) |
Sets the output room size.
The output room is the minimum pool size for select/blocking mode.
size | Output room size |
Definition at line 2412 of file alsaclient.cpp.
void setPoolInfo | ( | const PoolInfo & | info | ) |
Applies (updates) the client's PoolInfo data into the system.
info | The PoolInfo reference to be applied to the client. |
Definition at line 1348 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void setPoolInput | ( | int | size | ) |
Sets the size of the client's input pool.
size | The new size |
Definition at line 1379 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void setPoolOutput | ( | int | size | ) |
Sets the size of the client's output pool.
size | The new size |
Definition at line 1389 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
void setPoolOutputRoom | ( | int | size | ) |
Sets the room size of the client's output pool.
size | The new size |
Definition at line 1399 of file alsaclient.cpp.
References DRUMSTICK_ALSA_CHECK_WARNING.
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.
enable | real-time priority enabled |
Definition at line 354 of file alsaclient.cpp.
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.
val | a ClientInfo object reference |
Definition at line 791 of file alsaclient.cpp.
bool stopped | ( | ) |
Returns true or false depending on the input thread state.
Definition at line 1708 of file alsaclient.cpp.
void synchronizeOutput | ( | ) |
Wait until all sent events are processed.
This function waits until all events of this client are processed.
Definition at line 1087 of file alsaclient.cpp.
Referenced by SequencerOutputThread::syncOutput().
SystemInfo | ( | const SystemInfo & | other | ) |
Copy constructor.
other | Another SystemInfo object reference to be copied |
Definition at line 2133 of file alsaclient.cpp.
|
explicit |
Constructor.
seq | A MidiClient object |
Definition at line 2153 of file alsaclient.cpp.
References MidiClient::getHandle().
|
explicit |
Copy constructor.
other | Another ALSA system info object to be copied |
Definition at line 2143 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.
name | An existing queue name. |
Definition at line 1161 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.
queue_id | An existing queue identifier. |
Definition at line 1144 of file alsaclient.cpp.
Associate an existing MidiQueue instance to the client.
queue | An existing MidiQueue. |
Definition at line 1180 of file alsaclient.cpp.
|
virtual |
Destructor.
The ports and queue associated to this client are automatically released.
Definition at line 271 of file alsaclient.cpp.
References MidiClient::close(), MidiClient::detachAllPorts(), MidiClient::freeClients(), and MidiClient::stopSequencerInput().