24#include <QWriteLocker>
56const int TIMEOUT = 100;
167 unsigned int last_tick;
174 if (last_tick == 0) {
204 qWarning(
"exception in output thread");
219 QThread::start( priority );
Classes managing ALSA Sequencer clients.
Classes managing ALSA Sequencer queues.
The QThread class provides platform-independent threads.
MidiQueue * getQueue()
Get the MidiQueue instance associated to this client.
snd_seq_t * getHandle()
Returns the sequencer handler managed by ALSA.
int getClientId()
Gets the client ID.
void setTickPosition(snd_seq_tick_time_t pos)
Sets the queue position in musical time (ticks).
void continueRunning()
Start the queue without resetting the last position.
QueueStatus & getStatus()
Gets a QueueStatus object reference.
void start()
Start the queue.
void stop()
Stop the queue.
void clear()
Clear the queue, dropping any scheduled events.
int getEvents()
Gets the number of queued events.
Base class for the event's hierarchy.
static bool isConnectionChange(const SequencerEvent *event)
Checks if the event's type is of type connection change.
snd_seq_event_t * getHandle()
Gets the handle of the event.
void scheduleTick(const int queue, const int tick, const bool relative)
Sets the event to be scheduled in musical time (ticks) units.
void setDestination(const unsigned char client, const unsigned char port)
Sets the client:port destination of the event.
void setSource(const unsigned char port)
Sets the event's source port ID.
virtual SequencerEvent * nextEvent()=0
Gets the next event in the sequence.
virtual void run()
Thread process loop.
virtual unsigned int getInitialPosition()
Gets the initial position in ticks of the sequence.
virtual void sendEchoEvent(int tick)
Sends an echo event, with the same PortId as sender and destination.
SequencerOutputThread(MidiClient *seq, int portId)
Constructor.
virtual void syncOutput()
Waits until the ALSA output queue is empty (all the events have been played.)
int m_QueueId
MidiQueue numeric identifier.
MidiClient * m_MidiClient
MidiClient instance pointer.
bool m_Stopped
Stopped status.
virtual void stop()
Stops playing the current sequence.
virtual void sendSongEvent(SequencerEvent *ev)
Sends a SequencerEvent.
virtual void drainOutput()
Flush the ALSA output buffer.
pollfd * m_pfds
Array of pollfd pointers.
QReadWriteLock m_mutex
Mutex object used for synchronization.
MidiQueue * m_Queue
MidiQueue instance pointer.
virtual bool hasNext()=0
Check if there is one more event in the sequence.
virtual unsigned int getEchoResolution()
Gets the echo event resolution in ticks.
void stopped()
Signal emitted when the play-back has stopped.
int m_npfds
Number of pollfd pointers.
int m_PortId
MidiPort numeric identifier.
void start(Priority priority=InheritPriority)
Starts the playback thread.
virtual bool stopRequested()
Checks if stop has been requested.
void finished()
Signal emitted when the sequence play-back has finished.