Jack2
1.9.8
|
00001 /* 00002 Copyright (C) 2001 Paul Davis 00003 Copyright (C) 2004-2008 Grame 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU Lesser General Public License as published by 00007 the Free Software Foundation; either version 2.1 of the License, or 00008 (at your option) any later version. 00009 00010 This program 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 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 */ 00020 00021 #ifndef __JackTransportEngine__ 00022 #define __JackTransportEngine__ 00023 00024 #include "JackAtomicArrayState.h" 00025 #include "JackCompilerDeps.h" 00026 #include "types.h" 00027 00028 namespace Jack 00029 { 00030 00031 typedef enum { 00032 TransportCommandNone = 0, 00033 TransportCommandStart = 1, 00034 TransportCommandStop = 2, 00035 } transport_command_t; 00036 00090 class JackClientInterface; 00091 00092 PRE_PACKED_STRUCTURE 00093 class SERVER_EXPORT JackTransportEngine : public JackAtomicArrayState<jack_position_t> 00094 { 00095 00096 private: 00097 00098 jack_transport_state_t fTransportState; 00099 volatile transport_command_t fTransportCmd; 00100 transport_command_t fPreviousCmd; /* previous transport_cmd */ 00101 jack_time_t fSyncTimeout; 00102 int fSyncTimeLeft; 00103 int fTimeBaseMaster; 00104 bool fPendingPos; 00105 bool fNetworkSync; 00106 bool fConditionnal; 00107 SInt32 fWriteCounter; 00108 00109 bool CheckAllRolling(JackClientInterface** table); 00110 void MakeAllStartingLocating(JackClientInterface** table); 00111 void MakeAllStopping(JackClientInterface** table); 00112 void MakeAllLocating(JackClientInterface** table); 00113 00114 void SyncTimeout(jack_nframes_t frame_rate, jack_nframes_t buffer_size); 00115 00116 public: 00117 00118 JackTransportEngine(); 00119 00120 ~JackTransportEngine() 00121 {} 00122 00123 void SetCommand(transport_command_t state) 00124 { 00125 fTransportCmd = state; 00126 } 00127 00128 jack_transport_state_t GetState() const 00129 { 00130 return fTransportState; 00131 } 00132 00133 void SetState(jack_transport_state_t state) 00134 { 00135 fTransportState = state; 00136 } 00137 00138 /* 00139 \brief 00140 */ 00141 int ResetTimebase(int refnum); 00142 00143 /* 00144 \brief 00145 */ 00146 int SetTimebaseMaster(int refnum, bool conditionnal); 00147 00148 void GetTimebaseMaster(int& refnum, bool& conditionnal) 00149 { 00150 refnum = fTimeBaseMaster; 00151 conditionnal = fConditionnal; 00152 } 00153 00154 /* 00155 \brief 00156 */ 00157 void CycleBegin(jack_nframes_t frame_rate, jack_time_t time); 00158 00159 /* 00160 \brief 00161 */ 00162 void CycleEnd(JackClientInterface** table, jack_nframes_t frame_rate, jack_nframes_t buffer_size); 00163 00164 /* 00165 \brief 00166 */ 00167 void SetSyncTimeout(jack_time_t timeout) 00168 { 00169 fSyncTimeout = timeout; 00170 } 00171 00172 void ReadCurrentPos(jack_position_t* pos); 00173 00174 jack_unique_t GenerateUniqueID() 00175 { 00176 return (jack_unique_t)INC_ATOMIC(&fWriteCounter); 00177 } 00178 00179 void RequestNewPos(jack_position_t* pos); 00180 00181 jack_transport_state_t Query(jack_position_t* pos); 00182 00183 jack_nframes_t GetCurrentFrame(); 00184 00185 static void CopyPosition(jack_position_t* from, jack_position_t* to); 00186 00187 bool GetNetworkSync() const 00188 { 00189 return fNetworkSync; 00190 } 00191 00192 void SetNetworkSync(bool sync) 00193 { 00194 fNetworkSync = sync; 00195 } 00196 00197 } POST_PACKED_STRUCTURE; 00198 00199 } // end of namespace 00200 00201 #endif