jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.7KB

  1. /*
  2. Copyright (C) 2004-2008 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #include "JackGlobals.h"
  16. namespace Jack
  17. {
  18. bool JackGlobals::fVerbose = 0;
  19. jack_tls_key JackGlobals::fRealTimeThread;
  20. static bool gKeyRealtimeThreadInitialized = jack_tls_allocate_key(&JackGlobals::fRealTimeThread);
  21. jack_tls_key JackGlobals::fNotificationThread;
  22. static bool gKeyNotificationThreadInitialized = jack_tls_allocate_key(&JackGlobals::fNotificationThread);
  23. jack_tls_key JackGlobals::fKeyLogFunction;
  24. static bool fKeyLogFunctionInitialized = jack_tls_allocate_key(&JackGlobals::fKeyLogFunction);
  25. JackMutex* JackGlobals::fOpenMutex = new JackMutex();
  26. JackMutex* JackGlobals::fSynchroMutex = new JackMutex();
  27. volatile bool JackGlobals::fServerRunning = false;
  28. JackClient* JackGlobals::fClientTable[CLIENT_NUM] = {};
  29. #ifndef WIN32
  30. jack_thread_creator_t JackGlobals::fJackThreadCreator = pthread_create;
  31. #endif
  32. #ifdef __CLIENTDEBUG__
  33. std::ofstream* JackGlobals::fStream = NULL;
  34. void JackGlobals::CheckContext(const char* name)
  35. {
  36. if (JackGlobals::fStream == NULL) {
  37. char provstr[256];
  38. char buffer[256];
  39. time_t curtime;
  40. struct tm *loctime;
  41. /* Get the current time. */
  42. curtime = time (NULL);
  43. /* Convert it to local time representation. */
  44. loctime = localtime (&curtime);
  45. strftime(buffer, 256, "%I-%M", loctime);
  46. snprintf(provstr, sizeof(provstr), "JackAPICall-%s.log", buffer);
  47. JackGlobals::fStream = new std::ofstream(provstr, std::ios_base::ate);
  48. JackGlobals::fStream->is_open();
  49. }
  50. #ifdef PTHREAD_WIN32 /* Added by JE - 10-10-2011 */
  51. (*fStream) << "JACK API call : " << name << ", calling thread : " << pthread_self().p << std::endl;
  52. #elif defined(WIN32) && !defined(__CYGWIN__)
  53. (*fStream) << "JACK API call : " << name << ", calling thread : " << GetCurrentThread() << std::endl;
  54. #else
  55. (*fStream) << "JACK API call : " << name << ", calling thread : " << pthread_self() << std::endl;
  56. #endif
  57. }
  58. #else
  59. void JackGlobals::CheckContext(const char* name)
  60. {}
  61. #endif
  62. } // end of namespace