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.

126 lines
2.6KB

  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 General Public License as published by
  5. the Free Software Foundation; either version 2 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 General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #include "JackGlobals.h"
  16. #include "JackError.h"
  17. namespace Jack
  18. {
  19. JackFactoryImpl* JackGlobals::fInstance;
  20. void JackGlobals::InitServer()
  21. {
  22. jack_log("JackGlobals InitServer");
  23. if (!fInstance) {
  24. #ifdef __APPLE__
  25. fInstance = new JackFactoryOSXServer();
  26. #endif
  27. #ifdef WIN32
  28. fInstance = new JackFactoryWindowsServer();
  29. #endif
  30. #ifdef __linux__
  31. fInstance = new JackFactoryLinuxServer();
  32. #endif
  33. }
  34. }
  35. void JackGlobals::InitClient()
  36. {
  37. jack_log("JackGlobals InitClient");
  38. if (!fInstance) {
  39. #ifdef __APPLE__
  40. fInstance = new JackFactoryOSXClient();
  41. #endif
  42. #ifdef WIN32
  43. fInstance = new JackFactoryWindowsClient();
  44. #endif
  45. #ifdef __linux__
  46. fInstance = new JackFactoryLinuxClient();
  47. #endif
  48. }
  49. }
  50. void JackGlobals::Destroy()
  51. {
  52. jack_log("JackGlobals Destroy");
  53. if (fInstance) {
  54. delete fInstance;
  55. fInstance = NULL;
  56. }
  57. }
  58. } // end of namespace
  59. static bool gKeyRealtimeInitialized = false;
  60. static bool g_key_log_function_initialized = false;
  61. jack_tls_key gRealTime;
  62. jack_tls_key g_key_log_function;
  63. void jack_init()
  64. {
  65. if (!gKeyRealtimeInitialized) {
  66. gKeyRealtimeInitialized = jack_tls_allocate_key(&gRealTime);
  67. }
  68. if (!g_key_log_function_initialized)
  69. g_key_log_function_initialized = jack_tls_allocate_key(&g_key_log_function);
  70. }
  71. void jack_uninit()
  72. {
  73. if (gKeyRealtimeInitialized) {
  74. jack_tls_free_key(gRealTime);
  75. gKeyRealtimeInitialized = false;
  76. }
  77. if (g_key_log_function_initialized) {
  78. jack_tls_free_key(g_key_log_function);
  79. g_key_log_function_initialized = false;
  80. }
  81. }
  82. // Initialisation at library load time
  83. #ifdef WIN32
  84. BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  85. {
  86. switch (fdwReason) {
  87. case DLL_PROCESS_ATTACH:
  88. jack_init();
  89. break;
  90. case DLL_PROCESS_DETACH:
  91. jack_uninit();
  92. break;
  93. }
  94. return TRUE;
  95. }
  96. #endif