drumstick 1.1.3
playthread.h
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2019, 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 2 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
33namespace drumstick {
34
35class MidiClient;
36class MidiQueue;
37
46class DRUMSTICK_EXPORT SequencerOutputThread : public QThread
47{
48 Q_OBJECT
49
50public:
51 SequencerOutputThread(MidiClient *seq, int portId);
52 virtual void run();
57 virtual unsigned int getInitialPosition() { return 0; }
64 virtual unsigned int getEchoResolution() { return 0; }
71 virtual bool hasNext() = 0;
78 virtual SequencerEvent* nextEvent() = 0;
79
83 virtual void stop();
84
85signals:
89 void finished();
90
95 void stopped();
96
97public slots:
98 void start( Priority priority = InheritPriority );
99
100protected:
101 virtual void sendEchoEvent(int tick);
102 virtual void sendSongEvent(SequencerEvent* ev);
103 virtual void drainOutput();
104 virtual void syncOutput();
105 virtual bool stopRequested();
106
113 pollfd* m_pfds;
114 QReadWriteLock m_mutex;
115};
116
117} /* namespace drumstick */
118
121#endif /*DRUMSTICK_PLAYTHREAD_H*/
Classes managing ALSA Sequencer events.
The QThread class provides platform-independent threads.
Client management.
Definition alsaclient.h:198
Queue management.
Definition alsaqueue.h:188
Base class for the event's hierarchy.
Definition alsaevent.h:53
Sequence player auxiliary class.
Definition playthread.h:47
virtual SequencerEvent * nextEvent()=0
Gets the next event in the sequence.
virtual unsigned int getInitialPosition()
Gets the initial position in ticks of the sequence.
Definition playthread.h:57
int m_QueueId
MidiQueue numeric identifier.
Definition playthread.h:111
MidiClient * m_MidiClient
MidiClient instance pointer.
Definition playthread.h:107
bool m_Stopped
Stopped status.
Definition playthread.h:110
pollfd * m_pfds
Array of pollfd pointers.
Definition playthread.h:113
QReadWriteLock m_mutex
Mutex object used for synchronization.
Definition playthread.h:114
MidiQueue * m_Queue
MidiQueue instance pointer.
Definition playthread.h:108
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:64
void stopped()
Signal emitted when the play-back has stopped.
int m_npfds
Number of pollfd pointers.
Definition playthread.h:112
int m_PortId
MidiPort numeric identifier.
Definition playthread.h:109
void finished()
Signal emitted when the sequence play-back has finished.