2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
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.
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.
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.
21 #ifndef __JackFrameTimer__
22 #define __JackFrameTimer__
24 #include "JackAtomicState.h"
25 #include "JackCompilerDeps.h"
32 \brief A structure used for time management.
36 class SERVER_EXPORT JackTimer
39 friend class JackFrameTimer
;
43 jack_nframes_t fFrames
;
44 jack_time_t fCurrentWakeup
;
45 jack_time_t fCurrentCallback
;
46 jack_time_t fNextWakeUp
;
48 float fFilterOmega
; /* set once, never altered */
57 jack_nframes_t
Time2Frames(jack_time_t time
, jack_nframes_t buffer_size
);
58 jack_time_t
Frames2Time(jack_nframes_t frames
, jack_nframes_t buffer_size
);
59 jack_nframes_t
FramesSinceCycleStart(jack_time_t cur_time
, jack_nframes_t frames_rate
);
60 int GetCycleTimes(jack_nframes_t
* current_frames
, jack_time_t
* current_usecs
, jack_time_t
* next_usecs
, float* period_usecs
);
62 jack_nframes_t
CurFrame()
69 return fCurrentWakeup
;
72 } POST_PACKED_STRUCTURE
;
75 \brief A class using the JackAtomicState to manage jack time.
79 class SERVER_EXPORT JackFrameTimer
: public JackAtomicState
<JackTimer
>
85 void IncFrameTimeAux(jack_nframes_t buffer_size
, jack_time_t callback_usecs
, jack_time_t period_usecs
);
86 void InitFrameTimeAux(jack_time_t callback_usecs
, jack_time_t period_usecs
);
90 JackFrameTimer(): fFirstWakeUp(true)
96 void ResetFrameTime(jack_time_t callback_usecs
);
97 void IncFrameTime(jack_nframes_t buffer_size
, jack_time_t callback_usecs
, jack_time_t period_usecs
);
98 void ReadFrameTime(JackTimer
* timer
);
100 } POST_PACKED_STRUCTURE
;
103 } // end of namespace