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