00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __JackEngineControl__
00022 #define __JackEngineControl__
00023
00024 #include "JackShmMem.h"
00025 #include "JackFrameTimer.h"
00026 #include "JackTransportEngine.h"
00027 #include "types.h"
00028
00029 namespace Jack
00030 {
00031
00032 class JackClientInterface;
00033 class JackGraphManager;
00034
00035 #define TIME_POINTS 1000
00036 #define JACK_ENGINE_ROLLING_COUNT 32
00037 #define JACK_ENGINE_ROLLING_INTERVAL 1024
00038
00043 struct JackTimingMeasureClient
00044 {
00045 int fRefNum;
00046 jack_time_t fSignaledAt;
00047 jack_time_t fAwakeAt;
00048 jack_time_t fFinishedAt;
00049 jack_client_state_t fStatus;
00050 };
00051
00056 struct JackTimingMeasure
00057 {
00058 unsigned int fAudioCycle;
00059 jack_time_t fEngineTime;
00060 JackTimingMeasureClient fClientTable[CLIENT_NUM];
00061 };
00062
00067 struct JackEngineControl : public JackShmMem
00068 {
00069
00070 jack_nframes_t fBufferSize;
00071 jack_nframes_t fSampleRate;
00072 bool fSyncMode;
00073 bool fTemporary;
00074 jack_time_t fPeriodUsecs;
00075 jack_time_t fTimeOutUsecs;
00076 bool fTimeOut;
00077 bool fRealTime;
00078 int fPriority;
00079 char fServerName[64];
00080 JackTransportEngine fTransport;
00081 bool fVerbose;
00082
00083
00084 JackTimingMeasure fMeasure[TIME_POINTS];
00085 jack_time_t fLastTime;
00086 jack_time_t fCurTime;
00087 jack_time_t fProcessTime;
00088 jack_time_t fLastProcessTime;
00089 jack_time_t fSpareUsecs;
00090 jack_time_t fMaxUsecs;
00091 unsigned int fAudioCycle;
00092 jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT];
00093 int fRollingClientUsecsCnt;
00094 int fRollingClientUsecsIndex;
00095 int fRollingInterval;
00096 float fCPULoad;
00097
00098
00099 UInt64 fPeriod;
00100 UInt64 fComputation;
00101 UInt64 fConstraint;
00102
00103
00104 JackFrameTimer fFrameTimer;
00105
00106 JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, const char* server_name)
00107 {
00108 fSyncMode = sync;
00109 fTemporary = temporary;
00110 fTimeOut = (timeout > 0);
00111 fTimeOutUsecs = timeout * 1000;
00112 fRealTime = rt;
00113 fPriority = priority;
00114 fVerbose = verbose;
00115 fLastTime = 0;
00116 fCurTime = 0;
00117 fProcessTime = 0;
00118 fLastProcessTime = 0;
00119 fSpareUsecs = 0;
00120 fMaxUsecs = 0;
00121 fAudioCycle = 0;
00122 ClearTimeMeasures();
00123 ResetRollingUsecs();
00124 snprintf(fServerName, sizeof(fServerName), server_name);
00125 }
00126 ~JackEngineControl()
00127 {}
00128
00129
00130 void CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs);
00131 void CycleEnd(JackClientInterface** table);
00132
00133
00134 void InitFrameTime();
00135 void ResetFrameTime(jack_time_t callback_usecs);
00136 void ReadFrameTime(JackTimer* timer);
00137
00138
00139 void CalcCPULoad(JackClientInterface** table, JackGraphManager* manager);
00140 void GetTimeMeasure(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs);
00141 void ClearTimeMeasures();
00142 void ResetRollingUsecs();
00143
00144 };
00145
00146 }
00147
00148 #endif