JackTransportEngine.h

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 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 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 General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 */
00020 
00021 #ifndef __JackTransportEngine__
00022 #define __JackTransportEngine__
00023 
00024 #include "transport_types.h"
00025 #include "JackClientInterface.h"
00026 #include "JackConstants.h"
00027 #include "JackAtomicArrayState.h"
00028 
00029 namespace Jack
00030 {
00031 
00032 typedef enum {
00033     TransportCommandNone = 0,
00034     TransportCommandStart = 1,
00035     TransportCommandStop = 2,
00036 } transport_command_t;
00037 
00054 class JackTransportEngine : public JackAtomicArrayState<jack_position_t>
00055 {
00056 
00057     private:
00058 
00059         jack_transport_state_t fTransportState;
00060         volatile transport_command_t fTransportCmd;
00061         transport_command_t fPreviousCmd;               /* previous transport_cmd */
00062         jack_time_t fSyncTimeout;
00063         int fSyncTimeLeft;
00064         int fTimeBaseMaster;
00065         bool fPendingPos;
00066         SInt32 fWriteCounter;
00067 
00068         bool CheckOneSynching(JackClientInterface** table);
00069         bool CheckAllRolling(JackClientInterface** table);
00070         void MakeAllStarting(JackClientInterface** table);
00071         void SyncTimeout(jack_nframes_t frame_rate, jack_nframes_t buffer_size);
00072 
00073     public:
00074 
00075         JackTransportEngine();
00076 
00077         ~JackTransportEngine()
00078         {}
00079 
00080         void SetCommand(transport_command_t state)
00081         {
00082             fTransportCmd = state;
00083         }
00084 
00085         jack_transport_state_t GetState() const
00086         {
00087             return fTransportState;
00088         }
00089 
00090         int GetTimebaseMaster() const
00091         {
00092             return fTimeBaseMaster;
00093         }
00094 
00095         /*
00096                 \brief 
00097         */
00098         int ResetTimebase(int refnum);
00099 
00100         /*
00101                 \brief 
00102         */
00103         int SetTimebase(int refnum, bool conditionnal);
00104 
00105         /*
00106                 \brief 
00107         */
00108         void CycleBegin(jack_nframes_t frame_rate, jack_time_t time);
00109 
00110         /*
00111                 \brief 
00112         */
00113         void CycleEnd(JackClientInterface** table, jack_nframes_t frame_rate, jack_nframes_t buffer_size);
00114 
00115         /*
00116                 \brief 
00117         */
00118         void SetSyncTimeout(jack_time_t timeout)
00119         {
00120             fSyncTimeout = timeout;
00121         }
00122 
00123         void ReadCurrentPos(jack_position_t* pos);
00124 
00125         jack_unique_t GenerateUniqueID()
00126         {
00127             return (jack_unique_t)INC_ATOMIC(&fWriteCounter);
00128         }
00129 
00130         static void TransportCopyPosition(jack_position_t* from, jack_position_t* to);
00131 
00132 };
00133 
00134 
00135 } // end of namespace
00136 
00137 #endif

Generated on Thu Feb 14 11:16:02 2008 for Jackdmp by  doxygen 1.5.1