Init engine fields, cleanup.
[jack2.git] / common / JackEngineProfiling.h
blobc06487a006bed009b4833780899507ae67478e51
1 /*
2 Copyright (C) 2008 Grame & RTL
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.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __JackEngineProfiling__
21 #define __JackEngineProfiling__
23 #include "types.h"
24 #include "JackTypes.h"
25 #include "JackConstants.h"
26 #include "JackShmMem.h"
28 namespace Jack
31 #define TIME_POINTS 100000
32 #define FAILURE_TIME_POINTS 10000
33 #define FAILURE_WINDOW 10
34 #define MEASURED_CLIENTS 32
36 /*!
37 \brief Timing stucture for a client.
40 struct JackTimingMeasureClient
42 int fRefNum;
43 jack_time_t fSignaledAt;
44 jack_time_t fAwakeAt;
45 jack_time_t fFinishedAt;
46 jack_client_state_t fStatus;
48 JackTimingMeasureClient()
49 :fRefNum(-1),
50 fSignaledAt(0),
51 fAwakeAt(0),
52 fFinishedAt(0),
53 fStatus((jack_client_state_t)0)
56 } POST_PACKED_STRUCTURE;
58 /*!
59 \brief Timing interval in the global table for a given client
62 struct JackTimingClientInterval
64 int fRefNum;
65 char fName[JACK_CLIENT_NAME_SIZE + 1];
66 int fBeginInterval;
67 int fEndInterval;
69 JackTimingClientInterval()
70 :fRefNum(-1),
71 fBeginInterval(-1),
72 fEndInterval(-1)
75 } POST_PACKED_STRUCTURE;
77 /*!
78 \brief Timing stucture for a table of clients.
81 struct JackTimingMeasure
83 unsigned int fAudioCycle;
84 jack_time_t fPeriodUsecs;
85 jack_time_t fCurCycleBegin;
86 jack_time_t fPrevCycleEnd;
87 JackTimingMeasureClient fClientTable[CLIENT_NUM];
89 JackTimingMeasure()
90 :fAudioCycle(0),
91 fPeriodUsecs(0),
92 fCurCycleBegin(0),
93 fPrevCycleEnd(0)
96 } POST_PACKED_STRUCTURE;
98 /*!
99 \brief Client timing monitoring.
102 class JackClientInterface;
103 class JackGraphManager;
105 class SERVER_EXPORT JackEngineProfiling
108 private:
110 JackTimingMeasure fProfileTable[TIME_POINTS];
111 JackTimingClientInterval fIntervalTable[MEASURED_CLIENTS];
113 unsigned int fAudioCycle;
114 unsigned int fMeasuredClient;
116 bool CheckClient(const char* name, int cur_point);
118 public:
120 JackEngineProfiling();
121 ~JackEngineProfiling();
123 void Profile(JackClientInterface** table,
124 JackGraphManager* manager,
125 jack_time_t period_usecs,
126 jack_time_t cur_cycle_begin,
127 jack_time_t prev_cycle_end);
129 JackTimingMeasure* GetCurMeasure();
131 } POST_PACKED_STRUCTURE;
133 } // end of namespace
135 #endif