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 fPriority;
00057 char fServerName[64];
00058 JackTransportEngine fTransport;
00059 bool fVerbose;
00060
00061
00062 jack_time_t fPrevCycleTime;
00063 jack_time_t fCurCycleTime;
00064 jack_time_t fSpareUsecs;
00065 jack_time_t fMaxUsecs;
00066 jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT];
00067 int fRollingClientUsecsCnt;
00068 int fRollingClientUsecsIndex;
00069 int fRollingInterval;
00070 float fCPULoad;
00071
00072
00073 UInt64 fPeriod;
00074 UInt64 fComputation;
00075 UInt64 fConstraint;
00076
00077
00078 JackFrameTimer fFrameTimer;
00079
00080 JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, const char* server_name)
00081 {
00082 fBufferSize = 512;
00083 fSampleRate = 48000;
00084 fPeriodUsecs = jack_time_t(1000000.f / fSampleRate * fBufferSize);
00085 fSyncMode = sync;
00086 fTemporary = temporary;
00087 fTimeOut = (timeout > 0);
00088 fTimeOutUsecs = timeout * 1000;
00089 fRealTime = rt;
00090 fPriority = priority;
00091 fVerbose = verbose;
00092 fPrevCycleTime = 0;
00093 fCurCycleTime = 0;
00094 fSpareUsecs = 0;
00095 fMaxUsecs = 0;
00096 ResetRollingUsecs();
00097 snprintf(fServerName, sizeof(fServerName), server_name);
00098 fPeriod = 0;
00099 fComputation = 0;
00100 fConstraint = 0;
00101 fMaxDelayedUsecs = 0.f;
00102 fXrunDelayedUsecs = 0.f;
00103 }
00104 ~JackEngineControl()
00105 {}
00106
00107
00108 void CycleIncTime(jack_time_t callback_usecs);
00109 void CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end);
00110 void CycleEnd(JackClientInterface** table);
00111
00112
00113 void InitFrameTime();
00114 void ResetFrameTime(jack_time_t callback_usecs);
00115 void ReadFrameTime(JackTimer* timer);
00116
00117
00118 void NotifyXRun(float delayed_usecs);
00119 void ResetXRun();
00120
00121
00122 void CalcCPULoad(JackClientInterface** table, JackGraphManager* manager, jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end);
00123 void ResetRollingUsecs();
00124
00125 };
00126
00127 }
00128
00129 #endif