jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.0KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2006 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #ifndef __JackFrameTimer__
  17. #define __JackFrameTimer__
  18. #include "JackAtomicState.h"
  19. #include "types.h"
  20. namespace Jack
  21. {
  22. /*!
  23. \brief A structure used for time management.
  24. */
  25. struct JackTimer
  26. {
  27. jack_nframes_t fFrames;
  28. jack_time_t fCurrentWakeup;
  29. jack_time_t fCurrentCallback;
  30. jack_time_t fNextWakeUp;
  31. float fSecondOrderIntegrator;
  32. bool fInitialized;
  33. /* not accessed by clients */
  34. float fFilterCoefficient; /* set once, never altered */
  35. JackTimer();
  36. ~JackTimer()
  37. {}
  38. };
  39. /*!
  40. \brief A class using the JackAtomicState to manage jack time.
  41. */
  42. class JackFrameTimer : public JackAtomicState<JackTimer>
  43. {
  44. private:
  45. bool fFirstWakeUp;
  46. void IncFrameTimeAux(jack_nframes_t nframes, jack_time_t callback_usecs, jack_time_t period_usecs);
  47. public:
  48. JackFrameTimer(): fFirstWakeUp(true)
  49. {}
  50. ~JackFrameTimer()
  51. {}
  52. void Init();
  53. void InitFrameTime(jack_time_t callback_usecs, jack_time_t period_usecs);
  54. void ResetFrameTime(jack_nframes_t frames_rate, jack_time_t callback_usecs, jack_time_t period_usecs);
  55. void IncFrameTime(jack_nframes_t nframes, jack_time_t callback_usecs, jack_time_t period_usecs);
  56. void ReadFrameTime(JackTimer* timer);
  57. };
  58. } // end of namespace
  59. #endif