| 1 | /* |
|---|
| 2 | * Hydrogen |
|---|
| 3 | * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] |
|---|
| 4 | * |
|---|
| 5 | * http://www.hydrogen-music.org |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY, without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | * |
|---|
| 21 | */ |
|---|
| 22 | #ifndef H2CORE_JACKTIMEMASTER_H |
|---|
| 23 | #define H2CORE_JACKTIMEMASTER_H |
|---|
| 24 | |
|---|
| 25 | #include <QtCore/QMutex> |
|---|
| 26 | #include <jack/transport.h> |
|---|
| 27 | #include <hydrogen/JackTimeMasterEvents.h> |
|---|
| 28 | |
|---|
| 29 | namespace H2Core |
|---|
| 30 | { |
|---|
| 31 | class Song; |
|---|
| 32 | |
|---|
| 33 | class JackTimeMaster |
|---|
| 34 | { |
|---|
| 35 | public: |
|---|
| 36 | JackTimeMaster(); |
|---|
| 37 | ~JackTimeMaster(); |
|---|
| 38 | |
|---|
| 39 | bool setMaster(bool if_none_already = false); |
|---|
| 40 | void clearMaster(void); |
|---|
| 41 | void set_current_song(Song* s); |
|---|
| 42 | void set_heartbeat(bool* beat); |
|---|
| 43 | |
|---|
| 44 | private: |
|---|
| 45 | static void _callback(jack_transport_state_t state, |
|---|
| 46 | jack_nframes_t nframes, |
|---|
| 47 | jack_position_t* pos, |
|---|
| 48 | int new_pos, |
|---|
| 49 | void* arg); |
|---|
| 50 | void callback(jack_transport_state_t state, |
|---|
| 51 | jack_nframes_t nframes, |
|---|
| 52 | jack_position_t* pos, |
|---|
| 53 | int new_pos); |
|---|
| 54 | |
|---|
| 55 | private: |
|---|
| 56 | Song* m_pSong; |
|---|
| 57 | bool* m_pBeat; |
|---|
| 58 | QMutex m_mutex; |
|---|
| 59 | }; // class JackTimeMaster |
|---|
| 60 | |
|---|
| 61 | ///////////////////////////////////////////////////////////// |
|---|
| 62 | // FOR THE EVENT QUEUE DEFINES, SEE JackTimeMasterEvents.h // |
|---|
| 63 | ///////////////////////////////////////////////////////////// |
|---|
| 64 | |
|---|
| 65 | } // namespace H2Core |
|---|
| 66 | |
|---|
| 67 | #endif // H2CORE_H2TRANSPORT_H |
|---|