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-2008 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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. void InitFrameTimeAux(jack_time_t callback_usecs, jack_time_t period_usecs);
  48. public:
  49. JackFrameTimer(): fFirstWakeUp(true)
  50. {}
  51. ~JackFrameTimer()
  52. {}
  53. void InitFrameTime();
  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