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.

143 lines
3.2KB

  1. /*
  2. Copyright (C) 2008 Grame & RTL
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #ifndef __JackEngineProfiling__
  16. #define __JackEngineProfiling__
  17. #include "types.h"
  18. #include "JackTypes.h"
  19. #include "JackConstants.h"
  20. #include "JackShmMem.h"
  21. #include "JackGlobals.h"
  22. namespace Jack
  23. {
  24. #define TIME_POINTS 100000
  25. #define FAILURE_TIME_POINTS 10000
  26. #define FAILURE_WINDOW 10
  27. #define MEASURED_CLIENTS 32
  28. /*!
  29. \brief Timing structure for a client.
  30. */
  31. PRE_PACKED_STRUCTURE
  32. struct JackTimingMeasureClient
  33. {
  34. int fRefNum;
  35. jack_time_t fSignaledAt;
  36. jack_time_t fAwakeAt;
  37. jack_time_t fFinishedAt;
  38. jack_client_state_t fStatus;
  39. JackTimingMeasureClient()
  40. :fRefNum(-1),
  41. fSignaledAt(0),
  42. fAwakeAt(0),
  43. fFinishedAt(0),
  44. fStatus((jack_client_state_t)0)
  45. {}
  46. } POST_PACKED_STRUCTURE;
  47. /*!
  48. \brief Timing interval in the global table for a given client
  49. */
  50. PRE_PACKED_STRUCTURE
  51. struct JackTimingClientInterval
  52. {
  53. int fRefNum;
  54. char fName[JACK_CLIENT_NAME_SIZE + 1];
  55. int fBeginInterval;
  56. int fEndInterval;
  57. JackTimingClientInterval()
  58. :fRefNum(-1),
  59. fBeginInterval(-1),
  60. fEndInterval(-1)
  61. {}
  62. } POST_PACKED_STRUCTURE;
  63. /*!
  64. \brief Timing structure for a table of clients.
  65. */
  66. PRE_PACKED_STRUCTURE
  67. struct JackTimingMeasure
  68. {
  69. unsigned int fAudioCycle;
  70. jack_time_t fPeriodUsecs;
  71. jack_time_t fCurCycleBegin;
  72. jack_time_t fPrevCycleEnd;
  73. JackTimingMeasureClient fClientTable[CLIENT_NUM];
  74. JackTimingMeasure()
  75. :fAudioCycle(0),
  76. fPeriodUsecs(0),
  77. fCurCycleBegin(0),
  78. fPrevCycleEnd(0)
  79. {}
  80. } POST_PACKED_STRUCTURE;
  81. /*!
  82. \brief Client timing monitoring.
  83. */
  84. class JackClientInterface;
  85. class JackGraphManager;
  86. PRE_PACKED_STRUCTURE
  87. class SERVER_EXPORT JackEngineProfiling
  88. {
  89. private:
  90. JackGlobals* fGlobal;
  91. JackTimingMeasure fProfileTable[TIME_POINTS];
  92. JackTimingClientInterval fIntervalTable[MEASURED_CLIENTS];
  93. unsigned int fAudioCycle;
  94. unsigned int fMeasuredClient;
  95. bool CheckClient(const char* name, int cur_point);
  96. public:
  97. JackEngineProfiling(JackGlobals *global);
  98. ~JackEngineProfiling();
  99. void Profile(JackClientInterface** table,
  100. JackGraphManager* manager,
  101. jack_time_t period_usecs,
  102. jack_time_t cur_cycle_begin,
  103. jack_time_t prev_cycle_end);
  104. JackTimingMeasure* GetCurMeasure();
  105. } POST_PACKED_STRUCTURE;
  106. } // end of namespace
  107. #endif