Cleanup
[jack2.git] / common / JackEngineTiming.h
blob986e548d42aa3aaf1ba8b785f3d2e7b71e0cfffd
1 /*
2 Copyright (C) 2004-2006 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 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 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __JackEngineTiming__
21 #define __JackEngineTiming__
23 #include "types.h"
24 #include "JackGraphManager.h"
26 namespace Jack
29 #define TIME_POINTS 1000
30 #define JACK_ENGINE_ROLLING_COUNT 32
31 #define JACK_ENGINE_ROLLING_INTERVAL 1024
33 class JackClientInterface;
34 struct JackEngineControl;
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;
49 /*!
50 \brief Timing stucture for a table of clients.
53 struct JackTimingMeasure
55 long fAudioCycle;
56 jack_time_t fEngineTime;
57 JackTimingMeasureClient fClientTable[CLIENT_NUM];
60 /*!
61 \brief Engine timing management.
64 class JackEngineTiming
66 private:
68 JackClientInterface** fClientTable;
69 JackGraphManager* fGraphManager;
70 JackEngineControl* fEngineControl;
72 JackTimingMeasure fMeasure[TIME_POINTS];
73 jack_time_t fLastTime;
74 jack_time_t fCurTime;
75 jack_time_t fProcessTime;
76 jack_time_t fLastProcessTime;
77 jack_time_t fSpareUsecs;
78 jack_time_t fMaxUsecs;
79 uint32_t fAudioCycle;
81 jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT];
82 int fRollingClientUsecsCnt;
83 int fRollingClientUsecsIndex;
84 int fRollingInterval;
86 void CalcCPULoad();
87 void GetTimeMeasure(jack_time_t callback_usecs);
89 public:
91 JackEngineTiming(JackClientInterface** table, JackGraphManager* manager, JackEngineControl* control);
92 virtual ~JackEngineTiming()
95 void UpdateTiming(jack_time_t callback_usecs);
96 void ResetRollingUsecs();
98 void ClearTimeMeasures();
99 void PrintState();
102 } // end of namespace
104 #endif