drumstick 0.5.0
|
00001 /* 00002 MIDI Sequencer C++ library 00003 Copyright (C) 2006-2010, Pedro Lopez-Cabanillas <plcl@users.sf.net> 00004 00005 This library is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License along 00016 with this program; if not, write to the Free Software Foundation, Inc., 00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef DRUMSTICK_PLAYTHREAD_H 00021 #define DRUMSTICK_PLAYTHREAD_H 00022 00023 #include "alsaevent.h" 00024 #include <QThread> 00025 #include <QReadWriteLock> 00026 00034 namespace drumstick { 00035 00036 class MidiClient; 00037 class MidiQueue; 00038 00047 class DRUMSTICK_EXPORT SequencerOutputThread : public QThread 00048 { 00049 Q_OBJECT 00050 00051 public: 00052 SequencerOutputThread(MidiClient *seq, int portId); 00053 virtual void run(); 00058 virtual unsigned int getInitialPosition() { return 0; } 00065 virtual unsigned int getEchoResolution() { return 0; } 00072 virtual bool hasNext() = 0; 00079 virtual SequencerEvent* nextEvent() = 0; 00080 00084 virtual void stop(); 00085 00086 signals: 00090 void finished(); 00091 00096 void stopped(); 00097 00098 public slots: 00099 void start( Priority priority = InheritPriority ); 00100 00101 protected: 00102 virtual void sendEchoEvent(int tick); 00103 virtual void sendSongEvent(SequencerEvent* ev); 00104 virtual void drainOutput(); 00105 virtual void syncOutput(); 00106 virtual bool stopRequested(); 00107 00108 MidiClient *m_MidiClient; 00109 MidiQueue *m_Queue; 00110 int m_PortId; 00111 bool m_Stopped; 00112 int m_QueueId; 00113 int m_npfds; 00114 pollfd* m_pfds; 00115 QReadWriteLock m_mutex; 00116 }; 00117 00118 } /* namespace drumstick */ 00119 00122 #endif /*DRUMSTICK_PLAYTHREAD_H*/