drumstick  0.5.0
playthread.h
Go to the documentation of this file.
1 /*
2  MIDI Sequencer C++ library
3  Copyright (C) 2006-2010, 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 along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef DRUMSTICK_PLAYTHREAD_H
21 #define DRUMSTICK_PLAYTHREAD_H
22 
23 #include "alsaevent.h"
24 #include <QThread>
25 #include <QReadWriteLock>
26 
34 namespace drumstick {
35 
36 class MidiClient;
37 class MidiQueue;
38 
47 class DRUMSTICK_EXPORT SequencerOutputThread : public QThread
48 {
49  Q_OBJECT
50 
51 public:
52  SequencerOutputThread(MidiClient *seq, int portId);
53  virtual void run();
58  virtual unsigned int getInitialPosition() { return 0; }
65  virtual unsigned int getEchoResolution() { return 0; }
72  virtual bool hasNext() = 0;
79  virtual SequencerEvent* nextEvent() = 0;
80 
84  virtual void stop();
85 
86 signals:
90  void finished();
91 
96  void stopped();
97 
98 public slots:
99  void start( Priority priority = InheritPriority );
100 
101 protected:
102  virtual void sendEchoEvent(int tick);
103  virtual void sendSongEvent(SequencerEvent* ev);
104  virtual void drainOutput();
105  virtual void syncOutput();
106  virtual bool stopRequested();
107 
110  int m_PortId;
111  bool m_Stopped;
112  int m_QueueId;
113  int m_npfds;
114  pollfd* m_pfds;
115  QReadWriteLock m_mutex;
116 };
117 
118 } /* namespace drumstick */
119 
122 #endif /*DRUMSTICK_PLAYTHREAD_H*/
MidiQueue * m_Queue
MidiQueue instance pointer.
Definition: playthread.h:109
virtual unsigned int getEchoResolution()
Gets the echo event resolution in ticks.
Definition: playthread.h:65
virtual unsigned int getInitialPosition()
Gets the initial position in ticks of the sequence.
Definition: playthread.h:58
Base class for the event's hierarchy.
Definition: alsaevent.h:53
Queue management.
Definition: alsaqueue.h:188
int m_npfds
Number of pollfd pointers.
Definition: playthread.h:113
Client management.
Definition: alsaclient.h:198
Sequence player auxiliary class.
Definition: playthread.h:47
int m_QueueId
MidiQueue numeric identifier.
Definition: playthread.h:112
bool m_Stopped
Stopped status.
Definition: playthread.h:111
pollfd * m_pfds
Array of pollfd pointers.
Definition: playthread.h:114
MidiClient * m_MidiClient
MidiClient instance pointer.
Definition: playthread.h:108
The QThread class provides platform-independent threads.
int m_PortId
MidiPort numeric identifier.
Definition: playthread.h:110
Classes managing ALSA Sequencer events.
QReadWriteLock m_mutex
Mutex object used for synchronization.
Definition: playthread.h:115