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.

106 lines
2.4KB

  1. /*
  2. Copyright (C) 2004-2006 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #ifndef __JackEngineTiming__
  16. #define __JackEngineTiming__
  17. #include "types.h"
  18. #include "JackGraphManager.h"
  19. namespace Jack
  20. {
  21. #define TIME_POINTS 1000
  22. #define JACK_ENGINE_ROLLING_COUNT 32
  23. #define JACK_ENGINE_ROLLING_INTERVAL 1024
  24. class JackClientInterface;
  25. struct JackEngineControl;
  26. /*!
  27. \brief Timing stucture for a client.
  28. */
  29. struct JackTimingMeasureClient
  30. {
  31. int fRefNum;
  32. jack_time_t fSignaledAt;
  33. jack_time_t fAwakeAt;
  34. jack_time_t fFinishedAt;
  35. jack_client_state_t fStatus;
  36. };
  37. /*!
  38. \brief Timing stucture for a table of clients.
  39. */
  40. struct JackTimingMeasure
  41. {
  42. long fAudioCycle;
  43. jack_time_t fEngineTime;
  44. JackTimingMeasureClient fClientTable[CLIENT_NUM];
  45. };
  46. /*!
  47. \brief Engine timing management.
  48. */
  49. class JackEngineTiming
  50. {
  51. private:
  52. JackClientInterface** fClientTable;
  53. JackGraphManager* fGraphManager;
  54. JackEngineControl* fEngineControl;
  55. JackTimingMeasure fMeasure[TIME_POINTS];
  56. jack_time_t fLastTime;
  57. jack_time_t fCurTime;
  58. jack_time_t fProcessTime;
  59. jack_time_t fLastProcessTime;
  60. jack_time_t fSpareUsecs;
  61. jack_time_t fMaxUsecs;
  62. uint32_t fAudioCycle;
  63. jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT];
  64. int fRollingClientUsecsCnt;
  65. int fRollingClientUsecsIndex;
  66. int fRollingInterval;
  67. void CalcCPULoad();
  68. void GetTimeMeasure(jack_time_t callback_usecs);
  69. public:
  70. JackEngineTiming(JackClientInterface** table, JackGraphManager* manager, JackEngineControl* control);
  71. virtual ~JackEngineTiming()
  72. {}
  73. void UpdateTiming(jack_time_t callback_usecs);
  74. void ResetRollingUsecs();
  75. void ClearTimeMeasures();
  76. void PrintState();
  77. };
  78. } // end of namespace
  79. #endif