drumstick 2.0.0
playthread.h
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2020, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4
5 This library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef DRUMSTICK_PLAYTHREAD_H
20#define DRUMSTICK_PLAYTHREAD_H
21
22#include "alsaevent.h"
23#include <QThread>
24#include <QReadWriteLock>
25
26namespace drumstick { namespace ALSA {
27
32
33class MidiClient;
34class MidiQueue;
35
48class DRUMSTICK_EXPORT SequencerOutputThread : public QThread
49{
50 Q_OBJECT
51
52public:
53 SequencerOutputThread(MidiClient *seq, int portId);
54 virtual void run() override;
60 virtual unsigned int getInitialPosition() { return 0; }
67 virtual unsigned int getEchoResolution() { return 0; }
74 virtual bool hasNext() = 0;
81 virtual SequencerEvent* nextEvent() = 0;
82
86 virtual void stop();
87
88signals:
93
98
99public slots:
100 void start( QThread::Priority priority = InheritPriority );
101
102protected:
103 virtual void sendEchoEvent(int tick);
104 virtual void sendSongEvent(SequencerEvent* ev);
105 virtual void drainOutput();
106 virtual void syncOutput();
107 virtual bool stopRequested();
108
115 pollfd* m_pfds;
116 QReadWriteLock m_mutex;
117};
118
120
121}} /* namespace drumstick::ALSA */
122
123#endif /*DRUMSTICK_PLAYTHREAD_H*/
Classes managing ALSA Sequencer events.
The QThread class provides platform-independent threads.
Client management.
Definition alsaclient.h:209
Queue management.
Definition alsaqueue.h:191
Base class for the event's hierarchy.
Definition alsaevent.h:58
void playbackStopped()
Signal emitted when the play-back has stopped.
virtual SequencerEvent * nextEvent()=0
Gets the next event in the sequence.
void start(QThread::Priority priority=InheritPriority)
Starts the playback thread.
virtual unsigned int getInitialPosition()
Gets the initial position in ticks of the sequence.
Definition playthread.h:60
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.
Definition playthread.h:113
MidiClient * m_MidiClient
MidiClient instance pointer.
Definition playthread.h:109
void playbackFinished()
Signal emitted when the sequence play-back has finished.
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.
Definition playthread.h:115
QReadWriteLock m_mutex
Mutex object used for synchronization.
Definition playthread.h:116
MidiQueue * m_Queue
MidiQueue instance pointer.
Definition playthread.h:110
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.
Definition playthread.h:67
virtual void run() override
Thread process loop.
int m_npfds
Number of pollfd pointers.
Definition playthread.h:114
int m_PortId
MidiPort numeric identifier.
Definition playthread.h:111
virtual bool stopRequested()
Checks if stop has been requested.
Drumstick ALSA library wrapper.
Drumstick common.