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.

140 lines
3.1KB

  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. namespace Jack
  22. {
  23. #define TIME_POINTS 100000
  24. #define FAILURE_TIME_POINTS 10000
  25. #define FAILURE_WINDOW 10
  26. #define MEASURED_CLIENTS 32
  27. /*!
  28. \brief Timing structure for a client.
  29. */
  30. PRE_PACKED_STRUCTURE
  31. struct JackTimingMeasureClient
  32. {
  33. int fRefNum;
  34. jack_time_t fSignaledAt;
  35. jack_time_t fAwakeAt;
  36. jack_time_t fFinishedAt;
  37. jack_client_state_t fStatus;
  38. JackTimingMeasureClient()
  39. :fRefNum(-1),
  40. fSignaledAt(0),
  41. fAwakeAt(0),
  42. fFinishedAt(0),
  43. fStatus((jack_client_state_t)0)
  44. {}
  45. } POST_PACKED_STRUCTURE;
  46. /*!
  47. \brief Timing interval in the global table for a given client
  48. */
  49. PRE_PACKED_STRUCTURE
  50. struct JackTimingClientInterval
  51. {
  52. int fRefNum;
  53. char fName[JACK_CLIENT_NAME_SIZE + 1];
  54. int fBeginInterval;
  55. int fEndInterval;
  56. JackTimingClientInterval()
  57. :fRefNum(-1),
  58. fBeginInterval(-1),
  59. fEndInterval(-1)
  60. {}
  61. } POST_PACKED_STRUCTURE;
  62. /*!
  63. \brief Timing structure for a table of clients.
  64. */
  65. PRE_PACKED_STRUCTURE
  66. struct JackTimingMeasure
  67. {
  68. unsigned int fAudioCycle;
  69. jack_time_t fPeriodUsecs;
  70. jack_time_t fCurCycleBegin;
  71. jack_time_t fPrevCycleEnd;
  72. JackTimingMeasureClient fClientTable[CLIENT_NUM];
  73. JackTimingMeasure()
  74. :fAudioCycle(0),
  75. fPeriodUsecs(0),
  76. fCurCycleBegin(0),
  77. fPrevCycleEnd(0)
  78. {}
  79. } POST_PACKED_STRUCTURE;
  80. /*!
  81. \brief Client timing monitoring.
  82. */
  83. class JackClientInterface;
  84. class JackGraphManager;
  85. PRE_PACKED_STRUCTURE
  86. class SERVER_EXPORT JackEngineProfiling
  87. {
  88. private:
  89. JackTimingMeasure fProfileTable[TIME_POINTS];
  90. JackTimingClientInterval fIntervalTable[MEASURED_CLIENTS];
  91. unsigned int fAudioCycle;
  92. unsigned int fMeasuredClient;
  93. bool CheckClient(const char* name, int cur_point);
  94. public:
  95. JackEngineProfiling();
  96. ~JackEngineProfiling();
  97. void Profile(JackClientInterface** table,
  98. JackGraphManager* manager,
  99. jack_time_t period_usecs,
  100. jack_time_t cur_cycle_begin,
  101. jack_time_t prev_cycle_end);
  102. JackTimingMeasure* GetCurMeasure();
  103. } POST_PACKED_STRUCTURE;
  104. } // end of namespace
  105. #endif