Jack2 1.9.6

JackEngineProfiling.h

00001 /*
00002 Copyright (C) 2008 Grame & RTL
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU Lesser General Public License as published by
00006 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
00013 
00014 You should have received a copy of the GNU Lesser General Public License
00015 along with this program; if not, write to the Free Software 
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 
00018 */
00019 
00020 #ifndef __JackEngineProfiling__
00021 #define __JackEngineProfiling__
00022 
00023 #include "types.h"
00024 #include "JackTypes.h"
00025 #include "JackConstants.h"
00026 #include "JackShmMem.h"
00027 
00028 namespace Jack
00029 {
00030 
00031 #define TIME_POINTS 100000
00032 #define FAILURE_TIME_POINTS 10000
00033 #define FAILURE_WINDOW 10
00034 #define MEASURED_CLIENTS 32
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     JackTimingMeasureClient() 
00049         :fRefNum(-1),
00050         fSignaledAt(0),
00051         fAwakeAt(0),
00052         fFinishedAt(0),
00053         fStatus((jack_client_state_t)0)
00054     {}
00055     
00056 } POST_PACKED_STRUCTURE;
00057 
00062 struct JackTimingClientInterval
00063 {
00064     int fRefNum;
00065     char fName[JACK_CLIENT_NAME_SIZE + 1];
00066     int fBeginInterval;
00067     int fEndInterval;
00068     
00069     JackTimingClientInterval()
00070          :fRefNum(-1),
00071          fBeginInterval(-1),
00072          fEndInterval(-1)
00073     {}
00074     
00075 } POST_PACKED_STRUCTURE;
00076 
00081 struct JackTimingMeasure
00082 {
00083     unsigned int fAudioCycle;
00084     jack_time_t fPeriodUsecs;
00085     jack_time_t fCurCycleBegin;
00086     jack_time_t fPrevCycleEnd;
00087     JackTimingMeasureClient fClientTable[CLIENT_NUM];
00088     
00089     JackTimingMeasure()
00090         :fAudioCycle(0), 
00091         fPeriodUsecs(0),
00092         fCurCycleBegin(0),
00093         fPrevCycleEnd(0)
00094     {}
00095     
00096 } POST_PACKED_STRUCTURE;
00097 
00102 class JackClientInterface;
00103 class JackGraphManager;
00104 
00105 class SERVER_EXPORT JackEngineProfiling
00106 {
00107 
00108     private:
00109     
00110         JackTimingMeasure fProfileTable[TIME_POINTS];
00111         JackTimingClientInterval fIntervalTable[MEASURED_CLIENTS];
00112          
00113         unsigned int fAudioCycle;
00114         unsigned int fMeasuredClient;
00115         
00116         bool CheckClient(const char* name, int cur_point);
00117         
00118     public:
00119     
00120         JackEngineProfiling();
00121         ~JackEngineProfiling();
00122    
00123         void Profile(JackClientInterface** table, 
00124                     JackGraphManager* manager, 
00125                     jack_time_t period_usecs,
00126                     jack_time_t cur_cycle_begin, 
00127                     jack_time_t prev_cycle_end);
00128                     
00129         JackTimingMeasure* GetCurMeasure();
00130 
00131 } POST_PACKED_STRUCTURE;
00132 
00133 } // end of namespace
00134 
00135 #endif