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.

108 lines
2.5KB

  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. #if defined(HAVE_CONFIG_H)
  16. #include "config.h"
  17. #endif
  18. #include "JackGlobals.h"
  19. static bool gKeyRealtimeInitialized = false;
  20. static bool g_key_log_function_initialized = false;
  21. jack_tls_key gRealTime;
  22. jack_tls_key g_key_log_function;
  23. // Initialisation at library load time
  24. #ifdef WIN32
  25. static void jack_init()
  26. {
  27. if (!gKeyRealtimeInitialized) {
  28. gKeyRealtimeInitialized = jack_tls_allocate_key(&gRealTime);
  29. }
  30. if (!g_key_log_function_initialized)
  31. g_key_log_function_initialized = jack_tls_allocate_key(&g_key_log_function);
  32. }
  33. static void jack_uninit()
  34. {
  35. if (gKeyRealtimeInitialized) {
  36. jack_tls_free_key(gRealTime);
  37. gKeyRealtimeInitialized = false;
  38. }
  39. if (g_key_log_function_initialized) {
  40. jack_tls_free_key(g_key_log_function);
  41. g_key_log_function_initialized = false;
  42. }
  43. }
  44. #ifdef __cplusplus
  45. extern "C"
  46. {
  47. #endif
  48. BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  49. {
  50. switch (fdwReason) {
  51. case DLL_PROCESS_ATTACH:
  52. jack_init();
  53. break;
  54. case DLL_PROCESS_DETACH:
  55. jack_uninit();
  56. break;
  57. }
  58. return TRUE;
  59. }
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #else
  64. __attribute__ ((constructor))
  65. static void jack_init()
  66. {
  67. if (!gKeyRealtimeInitialized) {
  68. gKeyRealtimeInitialized = jack_tls_allocate_key(&gRealTime);
  69. }
  70. if (!g_key_log_function_initialized)
  71. g_key_log_function_initialized = jack_tls_allocate_key(&g_key_log_function);
  72. }
  73. __attribute__ ((destructor))
  74. static void jack_uninit()
  75. {
  76. if (gKeyRealtimeInitialized) {
  77. jack_tls_free_key(gRealTime);
  78. gKeyRealtimeInitialized = false;
  79. }
  80. if (g_key_log_function_initialized) {
  81. jack_tls_free_key(g_key_log_function);
  82. g_key_log_function_initialized = false;
  83. }
  84. }
  85. #endif