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 #include <stdio.h>
00029
00030 namespace Jack
00031 {
00032
00033 class JackClientInterface;
00034 class JackGraphManager;
00035
00036 #define JACK_ENGINE_ROLLING_COUNT 32
00037 #define JACK_ENGINE_ROLLING_INTERVAL 1024
00038
00043 struct SERVER_EXPORT JackEngineControl : public JackShmMem
00044 {
00045
00046 jack_nframes_t fBufferSize;
00047 jack_nframes_t fSampleRate;
00048 bool fSyncMode;
00049 bool fTemporary;
00050 jack_time_t fPeriodUsecs;
00051 jack_time_t fTimeOutUsecs;
00052 float fMaxDelayedUsecs;
00053 float fXrunDelayedUsecs;
00054 bool fTimeOut;
00055 bool fRealTime;
00056 int fServerPriority;
00057 int fClientPriority;
00058 int fMaxClientPriority;
00059 char fServerName[64];
00060 JackTransportEngine fTransport;
00061 bool fVerbose;
00062
00063
00064 jack_time_t fPrevCycleTime;
00065 jack_time_t fCurCycleTime;
00066 jack_time_t fSpareUsecs;
00067 jack_time_t fMaxUsecs;
00068 jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT];
00069 int fRollingClientUsecsCnt;
00070 int fRollingClientUsecsIndex;
00071 int fRollingInterval;
00072 float fCPULoad;
00073
00074
00075 UInt64 fPeriod;
00076 UInt64 fComputation;
00077 UInt64 fConstraint;
00078
00079
00080 JackFrameTimer fFrameTimer;
00081
00082 JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, const char* server_name)
00083 {
00084 fBufferSize = 512;
00085 fSampleRate = 48000;
00086 fPeriodUsecs = jack_time_t(1000000.f / fSampleRate * fBufferSize);
00087 fSyncMode = sync;
00088 fTemporary = temporary;
00089 fTimeOut = (timeout > 0);
00090 fTimeOutUsecs = timeout * 1000;
00091 fRealTime = rt;
00092 fServerPriority = priority;
00093 fClientPriority = (rt) ? priority - 5 : 0;
00094 fMaxClientPriority = (rt) ? priority - 1 : 0;
00095 fVerbose = verbose;
00096 fPrevCycleTime = 0;
00097 fCurCycleTime = 0;
00098 fSpareUsecs = 0;
00099 fMaxUsecs = 0;
00100 ResetRollingUsecs();
00101 strncpy(fServerName, server_name, sizeof(fServerName));
00102 fPeriod = 0;
00103 fComputation = 0;
00104 fConstraint = 0;
00105 fMaxDelayedUsecs = 0.f;
00106 fXrunDelayedUsecs = 0.f;
00107 }
00108 ~JackEngineControl()
00109 {}
00110
00111
00112 void CycleIncTime(jack_time_t callback_usecs);
00113 void CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end);
00114 void CycleEnd(JackClientInterface** table);
00115
00116
00117 void InitFrameTime();
00118 void ResetFrameTime(jack_time_t callback_usecs);
00119 void ReadFrameTime(JackTimer* timer);
00120
00121
00122 void NotifyXRun(float delayed_usecs);
00123 void ResetXRun();
00124
00125
00126 void CalcCPULoad(JackClientInterface** table, JackGraphManager* manager, jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end);
00127 void ResetRollingUsecs();
00128
00129 };
00130
00131 }
00132
00133 #endif