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.

84 lines
1.9KB

  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. #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. __attribute__ ((constructor))
  24. static void jack_init()
  25. {
  26. if (!gKeyRealtimeInitialized) {
  27. gKeyRealtimeInitialized = jack_tls_allocate_key(&gRealTime);
  28. }
  29. if (!g_key_log_function_initialized)
  30. g_key_log_function_initialized = jack_tls_allocate_key(&g_key_log_function);
  31. }
  32. __attribute__ ((destructor))
  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. // Initialisation at library load time
  45. #ifdef WIN32
  46. #ifdef __cplusplus
  47. extern "C"
  48. {
  49. #endif
  50. BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  51. {
  52. switch (fdwReason) {
  53. case DLL_PROCESS_ATTACH:
  54. jack_init();
  55. break;
  56. case DLL_PROCESS_DETACH:
  57. jack_uninit();
  58. break;
  59. }
  60. return TRUE;
  61. }
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif