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 
33 namespace drumstick {
34 
35 class MidiClient;
36 class MidiQueue;
37 
46 class DRUMSTICK_EXPORT SequencerOutputThread : public QThread
47 {
48  Q_OBJECT
49 
50 public:
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 
85 signals:
89  void finished();
90 
95  void stopped();
96 
97 public slots:
98  void start( Priority priority = InheritPriority );
99 
100 protected:
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 
109  int m_PortId;
110  bool m_Stopped;
111  int m_QueueId;
112  int m_npfds;
113  pollfd* m_pfds;
114  QReadWriteLock m_mutex;
115 };
116 
117 } /* namespace drumstick */
118 
121 #endif /*DRUMSTICK_PLAYTHREAD_H*/
MidiQueue * m_Queue
MidiQueue instance pointer.
Definition: playthread.h:108
virtual unsigned int getEchoResolution()
Gets the echo event resolution in ticks.
Definition: playthread.h:64
virtual unsigned int getInitialPosition()
Gets the initial position in ticks of the sequence.
Definition: playthread.h:57
Base class for the event's hierarchy.
Definition: alsaevent.h:52
Queue management.
Definition: alsaqueue.h:187
int m_npfds
Number of pollfd pointers.
Definition: playthread.h:112
Client management.
Definition: alsaclient.h:197
Sequence player auxiliary class.
Definition: playthread.h:46
int m_QueueId
MidiQueue numeric identifier.
Definition: playthread.h:111
bool m_Stopped
Stopped status.
Definition: playthread.h:110
pollfd * m_pfds
Array of pollfd pointers.
Definition: playthread.h:113
MidiClient * m_MidiClient
MidiClient instance pointer.
Definition: playthread.h:107
The QThread class provides platform-independent threads.
int m_PortId
MidiPort numeric identifier.
Definition: playthread.h:109
Classes managing ALSA Sequencer events.
QReadWriteLock m_mutex
Mutex object used for synchronization.
Definition: playthread.h:114