Jack2 1.9.8

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 PRE_PACKED_STRUCTURE
00041 struct JackTimingMeasureClient
00042 {
00043     int fRefNum;
00044     jack_time_t fSignaledAt;
00045     jack_time_t fAwakeAt;
00046     jack_time_t fFinishedAt;
00047     jack_client_state_t fStatus;
00048     
00049     JackTimingMeasureClient() 
00050         :fRefNum(-1),
00051         fSignaledAt(0),
00052         fAwakeAt(0),
00053         fFinishedAt(0),
00054         fStatus((jack_client_state_t)0)
00055     {}
00056     
00057 } POST_PACKED_STRUCTURE;
00058 
00063 PRE_PACKED_STRUCTURE
00064 struct JackTimingClientInterval
00065 {
00066     int fRefNum;
00067     char fName[JACK_CLIENT_NAME_SIZE + 1];
00068     int fBeginInterval;
00069     int fEndInterval;
00070     
00071     JackTimingClientInterval()
00072          :fRefNum(-1),
00073          fBeginInterval(-1),
00074          fEndInterval(-1)
00075     {}
00076     
00077 } POST_PACKED_STRUCTURE;
00078 
00083 PRE_PACKED_STRUCTURE
00084 struct JackTimingMeasure
00085 {
00086     unsigned int fAudioCycle;
00087     jack_time_t fPeriodUsecs;
00088     jack_time_t fCurCycleBegin;
00089     jack_time_t fPrevCycleEnd;
00090     JackTimingMeasureClient fClientTable[CLIENT_NUM];
00091     
00092     JackTimingMeasure()
00093         :fAudioCycle(0), 
00094         fPeriodUsecs(0),
00095         fCurCycleBegin(0),
00096         fPrevCycleEnd(0)
00097     {}
00098     
00099 } POST_PACKED_STRUCTURE;
00100 
00105 class JackClientInterface;
00106 class JackGraphManager;
00107 
00108 PRE_PACKED_STRUCTURE
00109 class SERVER_EXPORT JackEngineProfiling
00110 {
00111 
00112     private:
00113     
00114         JackTimingMeasure fProfileTable[TIME_POINTS];
00115         JackTimingClientInterval fIntervalTable[MEASURED_CLIENTS];
00116          
00117         unsigned int fAudioCycle;
00118         unsigned int fMeasuredClient;
00119         
00120         bool CheckClient(const char* name, int cur_point);
00121         
00122     public:
00123     
00124         JackEngineProfiling();
00125         ~JackEngineProfiling();
00126    
00127         void Profile(JackClientInterface** table, 
00128                     JackGraphManager* manager, 
00129                     jack_time_t period_usecs,
00130                     jack_time_t cur_cycle_begin, 
00131                     jack_time_t prev_cycle_end);
00132                     
00133         JackTimingMeasure* GetCurMeasure();
00134 
00135 } POST_PACKED_STRUCTURE;
00136 
00137 } // end of namespace
00138 
00139 #endif