00001 /* 00002 Copyright (C) 2004-2006 Grame 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 00018 */ 00019 00020 #ifndef __JackEngineTiming__ 00021 #define __JackEngineTiming__ 00022 00023 #include "types.h" 00024 #include "JackGraphManager.h" 00025 00026 namespace Jack 00027 { 00028 00029 #define TIME_POINTS 1000 00030 #define JACK_ENGINE_ROLLING_COUNT 32 00031 #define JACK_ENGINE_ROLLING_INTERVAL 1024 00032 00033 class JackClientInterface; 00034 struct JackEngineControl; 00035 00040 struct JackTimingMeasureClient 00041 { 00042 int fRefNum; 00043 jack_time_t fSignaledAt; 00044 jack_time_t fAwakeAt; 00045 jack_time_t fFinishedAt; 00046 jack_client_state_t fStatus; 00047 }; 00048 00053 struct JackTimingMeasure 00054 { 00055 long fAudioCycle; 00056 jack_time_t fEngineTime; 00057 JackTimingMeasureClient fClientTable[CLIENT_NUM]; 00058 }; 00059 00064 class JackEngineTiming 00065 { 00066 private: 00067 00068 JackClientInterface** fClientTable; 00069 JackGraphManager* fGraphManager; 00070 JackEngineControl* fEngineControl; 00071 00072 JackTimingMeasure fMeasure[TIME_POINTS]; 00073 jack_time_t fLastTime; 00074 jack_time_t fCurTime; 00075 jack_time_t fProcessTime; 00076 jack_time_t fLastProcessTime; 00077 jack_time_t fSpareUsecs; 00078 jack_time_t fMaxUsecs; 00079 uint32_t fAudioCycle; 00080 00081 jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT]; 00082 int fRollingClientUsecsCnt; 00083 int fRollingClientUsecsIndex; 00084 int fRollingInterval; 00085 00086 void CalcCPULoad(); 00087 void GetTimeMeasure(jack_time_t callback_usecs); 00088 00089 public: 00090 00091 JackEngineTiming(JackClientInterface** table, JackGraphManager* manager, JackEngineControl* control); 00092 virtual ~JackEngineTiming() 00093 {} 00094 00095 void UpdateTiming(jack_time_t callback_usecs); 00096 void ResetRollingUsecs(); 00097 00098 void ClearTimeMeasures(); 00099 void PrintState(); 00100 }; 00101 00102 } // end of namespace 00103 00104 #endif 00105