drumstick
1.1.0
|
Sequence player auxiliary class. More...
#include <playthread.h>
Public Slots | |
void | start (Priority priority=InheritPriority) |
Starts the playback thread. More... | |
Signals | |
void | finished () |
Signal emitted when the sequence play-back has finished. | |
void | stopped () |
Signal emitted when the play-back has stopped. More... | |
Public Member Functions | |
SequencerOutputThread (MidiClient *seq, int portId) | |
Constructor. More... | |
virtual void | run () |
Thread process loop. | |
virtual unsigned int | getInitialPosition () |
Gets the initial position in ticks of the sequence. More... | |
virtual unsigned int | getEchoResolution () |
Gets the echo event resolution in ticks. More... | |
virtual bool | hasNext ()=0 |
Check if there is one more event in the sequence. More... | |
virtual SequencerEvent * | nextEvent ()=0 |
Gets the next event in the sequence. More... | |
virtual void | stop () |
Stops playing the current sequence. More... | |
Protected Member Functions | |
virtual void | sendEchoEvent (int tick) |
Sends an echo event, with the same PortId as sender and destination. More... | |
virtual void | sendSongEvent (SequencerEvent *ev) |
Sends a SequencerEvent. More... | |
virtual void | drainOutput () |
Flush the ALSA output buffer. | |
virtual void | syncOutput () |
Waits until the ALSA output queue is empty (all the events have been played.) | |
virtual bool | stopRequested () |
Checks if stop has been requested. More... | |
Protected Attributes | |
MidiClient * | m_MidiClient |
MidiClient instance pointer. | |
MidiQueue * | m_Queue |
MidiQueue instance pointer. | |
int | m_PortId |
MidiPort numeric identifier. | |
bool | m_Stopped |
Stopped status. | |
int | m_QueueId |
MidiQueue numeric identifier. | |
int | m_npfds |
Number of pollfd pointers. | |
pollfd * | m_pfds |
Array of pollfd pointers. | |
QReadWriteLock | m_mutex |
Mutex object used for synchronization. | |
Sequence player auxiliary class.
This class is used to implement an asynchronous sequence player using ALSA sequencer scheduling
Examples: guiplayer.cpp and playsmf.cpp
Definition at line 47 of file playthread.h.
SequencerOutputThread | ( | MidiClient * | seq, |
int | portId | ||
) |
Constructor.
seq | Existing MidiClient object pointer |
portId | Numeric input/output port identifier |
Definition at line 63 of file playthread.cpp.
References MidiClient::getQueue(), SequencerOutputThread::m_MidiClient, SequencerOutputThread::m_Queue, and SequencerOutputThread::m_QueueId.
|
inlinevirtual |
Gets the echo event resolution in ticks.
This is the time between echo events interleaved with the MIDI sequence. The default value zero means that not echo events are sent at all.
Definition at line 65 of file playthread.h.
Referenced by SequencerOutputThread::run().
|
inlinevirtual |
Gets the initial position in ticks of the sequence.
Definition at line 58 of file playthread.h.
Referenced by SequencerOutputThread::run().
|
pure virtual |
Check if there is one more event in the sequence.
This is a pure virtual method that must be overridden in the derived class.
Referenced by SequencerOutputThread::run().
|
pure virtual |
Gets the next event in the sequence.
This is a pure virtual function that must be overridden in the derived class.
Referenced by SequencerOutputThread::run().
|
protectedvirtual |
Sends an echo event, with the same PortId as sender and destination.
tick | Event schedule time in ticks. |
Definition at line 109 of file playthread.cpp.
References MidiClient::getClientId(), SequencerOutputThread::m_MidiClient, SequencerOutputThread::m_PortId, SequencerOutputThread::m_QueueId, SequencerEvent::scheduleTick(), SequencerOutputThread::sendSongEvent(), SequencerEvent::setDestination(), SequencerEvent::setSource(), and SequencerOutputThread::stopRequested().
|
protectedvirtual |
Sends a SequencerEvent.
ev | SequencerEvent object pointer |
Definition at line 125 of file playthread.cpp.
References SequencerEvent::getHandle(), MidiClient::getHandle(), SequencerOutputThread::m_MidiClient, SequencerOutputThread::m_npfds, SequencerOutputThread::m_pfds, and SequencerOutputThread::stopRequested().
Referenced by SequencerOutputThread::sendEchoEvent().
|
slot |
Starts the playback thread.
priority | Thread priority, default is InheritPriority |
Definition at line 215 of file playthread.cpp.
References SequencerOutputThread::m_mutex, and SequencerOutputThread::m_Stopped.
|
virtual |
Stops playing the current sequence.
Stops the playback task.
Definition at line 95 of file playthread.cpp.
References SequencerOutputThread::m_mutex, and SequencerOutputThread::m_Stopped.
|
signal |
Signal emitted when the play-back has stopped.
|
protectedvirtual |
Checks if stop has been requested.
Definition at line 85 of file playthread.cpp.
References SequencerOutputThread::m_mutex, and SequencerOutputThread::m_Stopped.
Referenced by SequencerOutputThread::drainOutput(), SequencerOutputThread::run(), SequencerOutputThread::sendEchoEvent(), SequencerOutputThread::sendSongEvent(), and SequencerOutputThread::syncOutput().