Jack2  1.9.10
JackGlobals.cpp
00001 /*
00002 Copyright (C) 2004-2008 Grame
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 #include "JackGlobals.h"
00021 
00022 namespace Jack
00023 {
00024 
00025 bool JackGlobals::fVerbose = 0;
00026 
00027 jack_tls_key JackGlobals::fRealTimeThread;
00028 static bool gKeyRealtimeThreadInitialized = jack_tls_allocate_key(&JackGlobals::fRealTimeThread);
00029 
00030 jack_tls_key JackGlobals::fNotificationThread;
00031 static bool gKeyNotificationThreadInitialized = jack_tls_allocate_key(&JackGlobals::fNotificationThread);
00032 
00033 jack_tls_key JackGlobals::fKeyLogFunction;
00034 static bool fKeyLogFunctionInitialized = jack_tls_allocate_key(&JackGlobals::fKeyLogFunction);
00035 
00036 JackMutex* JackGlobals::fOpenMutex = new JackMutex();
00037 JackMutex* JackGlobals::fSynchroMutex = new JackMutex();
00038 volatile bool JackGlobals::fServerRunning = false;
00039 JackClient* JackGlobals::fClientTable[CLIENT_NUM] = {};
00040 
00041 #ifndef WIN32
00042 jack_thread_creator_t JackGlobals::fJackThreadCreator = pthread_create;
00043 #endif
00044 
00045 #ifdef __CLIENTDEBUG__
00046 
00047 std::ofstream* JackGlobals::fStream = NULL;
00048 
00049 void JackGlobals::CheckContext(const char* name)
00050 {
00051     if (JackGlobals::fStream == NULL) {
00052         char provstr[256];
00053         char buffer[256];
00054         time_t curtime;
00055         struct tm *loctime;
00056         /* Get the current time. */
00057         curtime = time (NULL);
00058         /* Convert it to local time representation. */
00059         loctime = localtime (&curtime);
00060         strftime(buffer, 256, "%I-%M", loctime);
00061         snprintf(provstr, sizeof(provstr), "JackAPICall-%s.log", buffer);
00062         JackGlobals::fStream = new std::ofstream(provstr, std::ios_base::ate);
00063         JackGlobals::fStream->is_open();
00064     }
00065 #ifdef PTHREAD_WIN32 /* Added by JE - 10-10-2011 */
00066     (*fStream) << "JACK API call : " << name << ", calling thread : " << pthread_self().p << std::endl;
00067 #elif defined(WIN32) && !defined(__CYGWIN__)
00068     (*fStream) << "JACK API call : " << name << ", calling thread : " << GetCurrentThread() << std::endl;
00069 #else
00070     (*fStream) << "JACK API call : " << name << ", calling thread : " << pthread_self() << std::endl;
00071 #endif
00072 }
00073 
00074 #else
00075 
00076 void JackGlobals::CheckContext(const char* name)
00077 {}
00078 
00079 #endif
00080 
00081 } // end of namespace