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
34namespace drumstick {
35
36class MidiClient;
37class MidiQueue;
38
47class DRUMSTICK_EXPORT SequencerOutputThread : public QThread
48{
49 Q_OBJECT
50
51public:
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
86signals:
90 void finished();
91
96 void stopped();
97
98public slots:
99 void start( Priority priority = InheritPriority );
100
101protected:
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
114 pollfd* m_pfds;
115 QReadWriteLock m_mutex;
116};
117
118} /* namespace drumstick */
119
122#endif /*DRUMSTICK_PLAYTHREAD_H*/
Classes managing ALSA Sequencer events.
The QThread class provides platform-independent threads.
Client management.
Definition alsaclient.h:199
Queue management.
Definition alsaqueue.h:189
Base class for the event's hierarchy.
Definition alsaevent.h:54
Sequence player auxiliary class.
Definition playthread.h:48
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:58
int m_QueueId
MidiQueue numeric identifier.
Definition playthread.h:112
MidiClient * m_MidiClient
MidiClient instance pointer.
Definition playthread.h:108
bool m_Stopped
Stopped status.
Definition playthread.h:111
pollfd * m_pfds
Array of pollfd pointers.
Definition playthread.h:114
QReadWriteLock m_mutex
Mutex object used for synchronization.
Definition playthread.h:115
MidiQueue * m_Queue
MidiQueue instance pointer.
Definition playthread.h:109
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:65
void stopped()
Signal emitted when the play-back has stopped.
int m_npfds
Number of pollfd pointers.
Definition playthread.h:113
int m_PortId
MidiPort numeric identifier.
Definition playthread.h:110
void finished()
Signal emitted when the sequence play-back has finished.