Jack2 1.9.6

JackProfiler.h

00001 /*
00002 Copyright (C) 2009 Grame
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 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 General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 
00018 */
00019 
00020 #ifndef __JackProfiler__
00021 #define __JackProfiler__
00022 
00023 #include "JackConstants.h"
00024 #include "JackPlatformPlug.h"
00025 #include "jack.h"
00026 #include "jslist.h"
00027 #include <map>
00028 #include <string>
00029 
00030 #ifdef JACK_MONITOR
00031 #include "JackEngineProfiling.h"
00032 #endif
00033 
00034 namespace Jack
00035 {
00036 
00037 struct JackProfilerClient {
00038 
00039     int fRefNum;
00040     jack_client_t* fClient;
00041     jack_port_t* fSchedulingPort;
00042     jack_port_t* fDurationPort;
00043     
00044     JackProfilerClient(jack_client_t* client, const char* name);
00045     ~JackProfilerClient();
00046     
00047 };
00048 
00053 class JackProfiler 
00054 {
00055 
00056     private:
00057     
00058         jack_client_t* fClient;
00059         jack_port_t* fCPULoadPort;
00060         jack_port_t* fDriverPeriodPort;
00061         jack_port_t* fDriverEndPort;
00062     #ifdef JACK_MONITOR
00063         JackTimingMeasure* fLastMeasure;
00064         std::map<std::string, JackProfilerClient*> fClientTable;
00065         JackMutex fMutex;
00066     #endif
00067  
00068     public:
00069 
00070         JackProfiler(jack_client_t* jack_client, const JSList* params);
00071         ~JackProfiler();
00072 
00073         static int Process(jack_nframes_t nframes, void* arg);
00074         static void ClientRegistration(const char* name, int val, void *arg);
00075 
00076 };
00077 
00078 }
00079 
00080 #endif