20#ifndef DRUMSTICK_ALSACLIENT_H
21#define DRUMSTICK_ALSACLIENT_H
26#include <QReadWriteLock>
41class SequencerInputThread;
52 friend class MidiClient;
77#if SND_LIB_VERSION > 0x010010
78 void addFilter(
int eventType);
79 bool isFiltered(
int eventType);
81 void removeFilter(
int eventType);
89 void setEventFilter(
unsigned char* filter) __attribute__((deprecated));
92 snd_seq_client_info_t* m_Info;
109 friend class MidiClient;
129 snd_seq_system_info_t* m_Info;
140 friend class MidiClient;
145 PoolInfo(snd_seq_client_pool_t* other);
163 snd_seq_client_pool_t* m_Info;
205 void open(
const QString deviceName =
"default",
206 const int openMode = SND_SEQ_OPEN_DUPLEX,
207 const bool blockMode =
false );
208 void open( snd_config_t* conf,
209 const QString deviceName =
"default",
210 const int openMode = SND_SEQ_OPEN_DUPLEX,
211 const bool blockMode =
false );
229 void drainOutput(
bool async =
false,
int timeout = -1);
239 size_t getOutputBufferSize();
240 void setOutputBufferSize(
size_t newSize);
241 size_t getInputBufferSize();
242 void setInputBufferSize(
size_t newSize);
249 void setBlockMode(
bool newValue);
250 QString getClientName();
251 QString getClientName(
const int clientId);
252 void setClientName(QString
const& newName);
253 bool getBroadcastFilter();
254 void setBroadcastFilter(
bool newValue);
255 bool getErrorBounce();
256 void setErrorBounce(
bool newValue);
259 void setThisClientInfo(
const ClientInfo& val);
265 QList<int> getAvailableQueues();
268 void setPoolInfo(
const PoolInfo& info);
269 void setPoolInput(
int size);
270 void setPoolOutput(
int size);
271 void setPoolOutputRoom(
int size);
272 void resetPoolInput();
273 void resetPoolOutput();
275 void dropInputBuffer();
277 void dropOutputBuffer();
281 int inputPending(
bool fetch);
282 int getQueueId(
const QString& name);
284 void addListener(
QObject* listener);
285 void removeListener(
QObject* listener);
286 void setEventsEnabled(
const bool bEnabled);
291 bool parseAddress(
const QString& straddr, snd_seq_addr& result );
292 void setRealTimeInput(
bool enabled);
293 bool realTimeInputEnabled();
310 int pollDescriptors(
struct pollfd *pfds,
unsigned int space,
short events);
319 void connectFrom(
int myport,
int client,
int port);
320 void connectTo(
int myport,
int client,
int port);
326 bool m_eventsEnabled;
328 bool m_NeedRefreshClientList;
330 QString m_DeviceName;
331 snd_seq_t* m_SeqHandle;
332 QPointer<SequencerInputThread> m_Thread;
333 QPointer<MidiQueue> m_Queue;
341 QObjectList m_listeners;
346#if SND_LIB_VERSION > 0x010004
347DRUMSTICK_EXPORT QString getRuntimeALSALibraryVersion();
348DRUMSTICK_EXPORT
int getRuntimeALSALibraryNumber();
QList< ClientInfo > ClientInfoList
List of sequencer client information.
DRUMSTICK_EXPORT QString getRuntimeALSADriverVersion()
Gets the runtime ALSA drivers version string.
DRUMSTICK_EXPORT int getRuntimeALSADriverNumber()
Gets the runtime ALSA drivers version number.
Classes managing ALSA Sequencer ports.
QList< MidiPort * > MidiPortList
List of Ports instances.
QList< PortInfo > PortInfoList
List of port information objects.
The QObject class is the base class of all Qt objects.
void setBroadcastFilter(bool val)
Sets the broadcast filter.
int getSizeOfInfo() const
Gets the size of the internal object.
bool getErrorBounce()
Gets the client's error bounce.
void readPorts(MidiClient *seq)
Read the client ports.
void setName(QString name)
Sets the client name.
const unsigned char * getEventFilter() __attribute__((deprecated))
Gets the client's event filter.
snd_seq_client_type_t getClientType()
Gets the client's type.
void setErrorBounce(bool val)
Sets the error bounce.
ClientInfo()
Default constructor.
bool getBroadcastFilter()
Gets the client's broadcast filter.
int getNumPorts()
Gets the client's port count.
void setClient(int client)
Sets the client identifier number.
ClientInfo & operator=(const ClientInfo &other)
Assignment operator.
QString getName()
Gets the client's name.
int getClientId()
Gets the client's numeric identifier.
void setEventFilter(unsigned char *filter) __attribute__((deprecated))
Sets the event filter.
int getEventLost()
Gets the number of lost events.
PortInfoList getPorts() const
Gets the ports list.
void freePorts()
Release the ports list.
ClientInfo * clone()
Clone the client info object.
void outputBuffer(SequencerEvent *ev)
Output an event using the library output buffer, without draining the buffer.
MidiQueue * useQueue(int queue_id)
Create a new MidiQueue instance using a queue already existing in the system, associating it to the c...
MidiQueue * createQueue()
Create and return a new MidiQueue associated to this client.
QString getDeviceName()
Returns the name of the sequencer device.
bool getEventsEnabled() const
Returns true if the events mode of delivery has been enabled.
int createSimplePort(const char *name, unsigned int caps, unsigned int type)
Create an ALSA sequencer port, without using MidiPort.
void startSequencerInput()
Starts reading events from the ALSA sequencer.
void readClients()
Reads the ALSA sequencer's clients list.
int pollDescriptors(struct pollfd *pfds, unsigned int space, short events)
Get poll descriptors.
void _setClientName(const char *name)
Sets the client name.
void disconnectTo(int myport, int client, int port)
Unsubscribe one port to another arbitrary sequencer client:port.
snd_seq_type_t getSequencerType()
Returns the type snd_seq_type_t of the given sequencer handle.
PortInfoList filterPorts(unsigned int filter)
Gets a list of the available user ports in the system, filtered by the given bitmap of desired capabi...
void applyClientInfo()
This internal method applies the ClientInfo data to the ALSA sequencer client.
void close()
Close the sequencer device.
MidiQueue * getQueue()
Get the MidiQueue instance associated to this client.
int getPollDescriptorsCount(short events)
Returns the number of poll descriptors.
void detachAllPorts()
Detach all the ports belonging to this client.
void stopSequencerInput()
Stops reading events from the ALSA sequencer.
void deleteSimplePort(int port)
Remove an ALSA sequencer port.
snd_seq_t * getHandle()
Returns the sequencer handler managed by ALSA.
void output(SequencerEvent *ev, bool async=false, int timeout=-1)
Output an event using the library output buffer.
int getOpenMode()
Returns the last open mode used in open()
MidiPort * createPort()
Create and attach a new MidiPort instance to this client.
void portDetach(MidiPort *port)
Detach a MidiPort instance from this client.
const char * _getDeviceName()
Gets the internal sequencer device name.
void setHandler(SequencerEventHandler *handler)
Sets a sequencer event handler enabling the callback delivery mode.
MidiClient(QObject *parent=0)
Constructor.
int getClientId()
Gets the client ID.
void doEvents()
Dispatch the events received from the Sequencer.
void open(const QString deviceName="default", const int openMode=SND_SEQ_OPEN_DUPLEX, const bool blockMode=false)
Open the sequencer device.
void disconnectFrom(int myport, int client, int port)
Unsubscribe one port from another arbitrary sequencer client:port.
void synchronizeOutput()
Wait until all sent events are processed.
void updateAvailablePorts()
Update the internal lists of user ports.
void freeClients()
Releases the list of ALSA sequencer's clients.
unsigned short pollDescriptorsRevents(struct pollfd *pfds, unsigned int nfds)
Gets the number of returned events from poll descriptors.
void connectFrom(int myport, int client, int port)
Subscribe one port from another arbitrary sequencer client:port.
void eventReceived(SequencerEvent *ev)
Signal emitted when an event is received.
void portAttach(MidiPort *port)
Attach a MidiPort instance to this client.
bool getBlockMode()
Returns the last block mode used in open()
void addEventFilter(int evtype)
Add an event filter to the client.
void outputDirect(SequencerEvent *ev, bool async=false, int timeout=-1)
Output an event directly to the sequencer.
void drainOutput(bool async=false, int timeout=-1)
Drain the library output buffer.
bool isOpened()
Returns true if the sequencer is opened.
void connectTo(int myport, int client, int port)
Subscribe one port to another arbitrary sequencer client:port.
Sequencer Pool information.
int getInputFree()
Gets the available size on input pool.
void setOutputRoom(int size)
Sets the output room size.
PoolInfo & operator=(const PoolInfo &other)
Assignment operator.
int getSizeOfInfo() const
Gets the size of the client pool object.
int getOutputRoom()
Gets the output room size.
PoolInfo()
Default constructor.
int getInputPool()
Gets the input pool size.
void setInputPool(int size)
Set the input pool size.
int getClientId()
Gets the client ID for this object.
int getOutputFree()
Gets the available size on output pool.
PoolInfo * clone()
Clone the pool info obeject.
void setOutputPool(int size)
Sets the output pool size.
int getOutputPool()
Gets the output pool size.
Auxiliary class to remove events from an ALSA queue.
Sequencer events handler.
virtual ~SequencerEventHandler()
Destructor.
virtual void handleSequencerEvent(SequencerEvent *ev)=0
Callback function to be implemented by the derived class.
Base class for the event's hierarchy.
int getSizeOfInfo() const
Get the system's info object size.
int getMaxQueues()
Get the system's maximum number of queues.
int getCurrentQueues()
Get the system's current number of queues.
int getMaxPorts()
Get the system's maximum number of ports.
int getMaxChannels()
Get the system's maximum number of channels.
SystemInfo * clone()
Clone the system info object.
SystemInfo & operator=(const SystemInfo &other)
Assignment operator.
int getCurrentClients()
Get the system's current number of clients.
int getMaxClients()
Get the system's maximum number of clients.
SystemInfo()
Default constructor.