drumstick 2.7.2
playthread.h
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2022, 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
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
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
Sequence player auxiliary class.
Definition: playthread.h:49
void playbackStopped()
Signal emitted when the play-back has stopped.
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:60
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.
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
int m_npfds
Number of pollfd pointers.
Definition: playthread.h:114
int m_PortId
MidiPort numeric identifier.
Definition: playthread.h:111
Drumstick common.
Definition: alsaclient.cpp:68