drumstick 2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.
playthread.h
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2023, 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
33#if defined(DRUMSTICK_STATIC)
34#define DRUMSTICK_ALSA_EXPORT
35#else
36#if defined(drumstick_alsa_EXPORTS)
37#define DRUMSTICK_ALSA_EXPORT Q_DECL_EXPORT
38#else
39#define DRUMSTICK_ALSA_EXPORT Q_DECL_IMPORT
40#endif
41#endif
42
43class MidiClient;
44class MidiQueue;
45
58class DRUMSTICK_ALSA_EXPORT SequencerOutputThread : public QThread
59{
60 Q_OBJECT
61
62public:
63 SequencerOutputThread(MidiClient *seq, int portId);
64 virtual void run() override;
70 virtual unsigned int getInitialPosition() { return 0; }
77 virtual unsigned int getEchoResolution() { return 0; }
84 virtual bool hasNext() = 0;
91 virtual SequencerEvent* nextEvent() = 0;
92
96 virtual void stop();
97
98Q_SIGNALS:
103
108
109public Q_SLOTS:
110 void start( QThread::Priority priority = InheritPriority );
111
112protected:
113 virtual void sendEchoEvent(int tick);
114 virtual void sendSongEvent(SequencerEvent* ev);
115 virtual void drainOutput();
116 virtual void syncOutput();
117 virtual bool stopRequested();
118
125 pollfd* m_pfds;
126 QReadWriteLock m_mutex;
127};
128
131}} /* namespace drumstick::ALSA */
132
133#endif /*DRUMSTICK_PLAYTHREAD_H*/
Classes managing ALSA Sequencer events.
The QThread class provides platform-independent threads.
Client management.
Definition: alsaclient.h:219
Queue management.
Definition: alsaqueue.h:201
Base class for the event's hierarchy.
Definition: alsaevent.h:68
Sequence player auxiliary class.
Definition: playthread.h:59
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:70
int m_QueueId
MidiQueue numeric identifier.
Definition: playthread.h:123
MidiClient * m_MidiClient
MidiClient instance pointer.
Definition: playthread.h:119
void playbackFinished()
Signal emitted when the sequence play-back has finished.
pollfd * m_pfds
Array of pollfd pointers.
Definition: playthread.h:125
QReadWriteLock m_mutex
Mutex object used for synchronization.
Definition: playthread.h:126
MidiQueue * m_Queue
MidiQueue instance pointer.
Definition: playthread.h:120
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:77
int m_npfds
Number of pollfd pointers.
Definition: playthread.h:124
int m_PortId
MidiPort numeric identifier.
Definition: playthread.h:121
Drumstick common.
Definition: alsaclient.cpp:68