JackEngineProfiling.h 2.95 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
Copyright (C) 2008 Grame & RTL
sletz's avatar
sletz committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

sletz's avatar
sletz committed
20
21
#ifndef __JackEngineProfiling__
#define __JackEngineProfiling__
sletz's avatar
sletz committed
22
23
24
25

#include "types.h"
#include "JackTypes.h"
#include "JackConstants.h"
sletz's avatar
sletz committed
26
#include "JackShmMem.h"
sletz's avatar
sletz committed
27
28
29
30

namespace Jack
{

sletz's avatar
sletz committed
31
#define TIME_POINTS 125000
sletz's avatar
sletz committed
32
33
#define FAILURE_TIME_POINTS 10000
#define FAILURE_WINDOW 10
sletz's avatar
sletz committed
34
#define MEASURED_CLIENTS 32
sletz's avatar
sletz committed
35
36
37
38
39
40
41
42
43
44
45
46

/*!
\brief Timing stucture for a client.
*/

struct JackTimingMeasureClient
{
    int fRefNum;
    jack_time_t	fSignaledAt;
    jack_time_t	fAwakeAt;
    jack_time_t	fFinishedAt;
    jack_client_state_t fStatus;
sletz's avatar
sletz committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    
    JackTimingMeasureClient() 
        :fRefNum(-1),
        fSignaledAt(0),
        fAwakeAt(0),
        fFinishedAt(0),
        fStatus((jack_client_state_t)0)
    {}
};

/*!
\brief Timing interval in the global table for a given client
*/

struct JackTimingClientInterval
{
    int fRefNum;
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fBeginInterval;
    int fEndInterval;
    
    JackTimingClientInterval()
         :fRefNum(-1),
         fBeginInterval(-1),
         fEndInterval(-1)
    {}
sletz's avatar
sletz committed
73
74
75
76
77
78
79
80
81
};

/*!
\brief Timing stucture for a table of clients.
*/

struct JackTimingMeasure
{
    unsigned int fAudioCycle;
sletz's avatar
sletz committed
82
83
84
    jack_time_t fPeriodUsecs;
    jack_time_t fCurCycleBegin;
    jack_time_t fPrevCycleEnd;
sletz's avatar
sletz committed
85
    JackTimingMeasureClient fClientTable[CLIENT_NUM];
sletz's avatar
sletz committed
86
87
88
89
90
91
92
    
    JackTimingMeasure()
        :fAudioCycle(0), 
        fPeriodUsecs(0),
        fCurCycleBegin(0),
        fPrevCycleEnd(0)
    {}
sletz's avatar
sletz committed
93
94
95
};

/*!
sletz's avatar
sletz committed
96
\brief Client timing monitoring.
sletz's avatar
sletz committed
97
98
99
100
101
*/

class JackClientInterface;
class JackGraphManager;

sletz's avatar
sletz committed
102
class SERVER_EXPORT JackEngineProfiling
sletz's avatar
sletz committed
103
104
105
106
{

    private:
    
sletz's avatar
sletz committed
107
        JackTimingMeasure fProfileTable[TIME_POINTS];
sletz's avatar
sletz committed
108
109
        JackTimingClientInterval fIntervalTable[MEASURED_CLIENTS];
         
sletz's avatar
sletz committed
110
        unsigned int fAudioCycle;
sletz's avatar
sletz committed
111
112
113
114
        unsigned int fMeasuredClient;
        
        bool CheckClient(const char* name, int cur_point);
        
sletz's avatar
sletz committed
115
116
    public:
    
sletz's avatar
sletz committed
117
118
119
120
121
122
123
124
125
126
        JackEngineProfiling();
        ~JackEngineProfiling();
   
        void Profile(JackClientInterface** table, 
                    JackGraphManager* manager, 
                    jack_time_t period_usecs,
                    jack_time_t cur_cycle_begin, 
                    jack_time_t prev_cycle_end);
                    
        JackTimingMeasure* GetCurMeasure();
sletz's avatar
sletz committed
127
128
129
130
131
132

};

} // end of namespace

#endif