Jack2 1.9.12

JackTransportEngine.h
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21 #ifndef __JackTransportEngine__
22 #define __JackTransportEngine__
23
24 #include "JackAtomicArrayState.h"
25 #include "JackCompilerDeps.h"
26 #include "types.h"
27
28 namespace Jack
29 {
30
31 typedef enum {
32 TransportCommandNone = 0,
33 TransportCommandStart = 1,
34 TransportCommandStop = 2,
35 } transport_command_t;
36
90 class JackClientInterface;
91
92 PRE_PACKED_STRUCTURE
93 class SERVER_EXPORT JackTransportEngine : public JackAtomicArrayState<jack_position_t>
94 {
95
96 private:
97
98 jack_transport_state_t fTransportState;
99 volatile transport_command_t fTransportCmd;
100 transport_command_t fPreviousCmd; /* previous transport_cmd */
101 jack_time_t fSyncTimeout;
102 int fSyncTimeLeft;
103 int fTimeBaseMaster;
104 bool fPendingPos;
105 bool fNetworkSync;
106 bool fConditionnal;
107 SInt32 fWriteCounter;
108
109 bool CheckAllRolling(JackClientInterface** table);
110 void MakeAllStartingLocating(JackClientInterface** table);
111 void MakeAllStopping(JackClientInterface** table);
112 void MakeAllLocating(JackClientInterface** table);
113
114 void SyncTimeout(jack_nframes_t frame_rate, jack_nframes_t buffer_size);
115
116 public:
117
118 JackTransportEngine();
119
120 ~JackTransportEngine()
121 {}
122
123 void SetCommand(transport_command_t state)
124 {
125 fTransportCmd = state;
126 }
127
128 jack_transport_state_t GetState() const
129 {
130 return fTransportState;
131 }
132
133 void SetState(jack_transport_state_t state)
134 {
135 fTransportState = state;
136 }
137
138 /*
139 \brief
140 */
141 int ResetTimebase(int refnum);
142
143 /*
144 \brief
145 */
146 int SetTimebaseMaster(int refnum, bool conditionnal);
147
148 void GetTimebaseMaster(int& refnum, bool& conditionnal)
149 {
150 refnum = fTimeBaseMaster;
151 conditionnal = fConditionnal;
152 }
153
154 /*
155 \brief
156 */
157 void CycleBegin(jack_nframes_t frame_rate, jack_time_t time);
158
159 /*
160 \brief
161 */
162 void CycleEnd(JackClientInterface** table, jack_nframes_t frame_rate, jack_nframes_t buffer_size);
163
164 /*
165 \brief
166 */
167 void SetSyncTimeout(jack_time_t timeout)
168 {
169 fSyncTimeout = timeout;
170 }
171
172 void ReadCurrentPos(jack_position_t* pos);
173
174 jack_unique_t GenerateUniqueID()
175 {
176 return (jack_unique_t)INC_ATOMIC(&fWriteCounter);
177 }
178
179 void RequestNewPos(jack_position_t* pos);
180
181 jack_transport_state_t Query(jack_position_t* pos);
182
183 jack_nframes_t GetCurrentFrame();
184
185 static void CopyPosition(jack_position_t* from, jack_position_t* to);
186
187 bool GetNetworkSync() const
188 {
189 return fNetworkSync;
190 }
191
192 void SetNetworkSync(bool sync)
193 {
194 fNetworkSync = sync;
195 }
196
197 } POST_PACKED_STRUCTURE;
198
199 } // end of namespace
200
201 #endif
_jack_position
Definition: types.h:554
Jack::JackTransportEngine
Definition: JackTransportEngine.h:93
Jack::JackAtomicArrayState
A class to handle several states in a lock-free manner.
Definition: JackAtomicArrayState.h:114
Jack::JackClientInterface
Client interface.
Definition: JackClientInterface.h:35