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.

283 lines
7.1KB

  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. #ifndef __JackGlobals__
  16. #define __JackGlobals__
  17. #include "JackError.h"
  18. #include "JackThread.h"
  19. #include "JackThread.h"
  20. #include "JackExports.h"
  21. namespace Jack
  22. {
  23. class JackSynchro;
  24. class JackServerNotifyChannelInterface;
  25. class JackClientChannelInterface;
  26. class JackNotifyChannelInterface;
  27. class JackServerChannelInterface;
  28. class JackSyncInterface;
  29. class JackThread;
  30. class JackDriverClientInterface;
  31. class JackRunnableInterface;
  32. class JackEngine;
  33. /*!
  34. \brief Factory description
  35. \todo possibly use in a dynamic way to test different communication/synchro implementations.
  36. */
  37. class JackFactoryImpl
  38. {
  39. public:
  40. JackFactoryImpl()
  41. {}
  42. virtual ~JackFactoryImpl()
  43. {}
  44. virtual JackSynchro* MakeSynchro() = 0;
  45. virtual JackServerNotifyChannelInterface* MakeServerNotifyChannel() = 0;
  46. virtual JackClientChannelInterface* MakeClientChannel() = 0;
  47. virtual JackNotifyChannelInterface* MakeNotifyChannel() = 0;
  48. virtual JackServerChannelInterface* MakeServerChannel() = 0;
  49. virtual JackSyncInterface* MakeInterProcessSync() = 0;
  50. virtual JackThread* MakeThread(JackRunnableInterface* runnable) = 0;
  51. };
  52. #ifdef __linux__
  53. class JackFactoryLinuxServer : public JackFactoryImpl
  54. {
  55. public:
  56. JackFactoryLinuxServer()
  57. {}
  58. virtual ~JackFactoryLinuxServer()
  59. {}
  60. JackSynchro* MakeSynchro();
  61. JackServerNotifyChannelInterface* MakeServerNotifyChannel();
  62. JackClientChannelInterface* MakeClientChannel();
  63. JackNotifyChannelInterface* MakeNotifyChannel();
  64. JackServerChannelInterface* MakeServerChannel();
  65. JackSyncInterface* MakeInterProcessSync();
  66. JackThread* MakeThread(JackRunnableInterface* runnable);
  67. };
  68. class JackFactoryLinuxClient : public JackFactoryImpl
  69. {
  70. public:
  71. JackFactoryLinuxClient()
  72. {}
  73. virtual ~JackFactoryLinuxClient()
  74. {}
  75. JackSynchro* MakeSynchro();
  76. JackServerNotifyChannelInterface* MakeServerNotifyChannel();
  77. JackClientChannelInterface* MakeClientChannel();
  78. JackNotifyChannelInterface* MakeNotifyChannel();
  79. JackServerChannelInterface* MakeServerChannel();
  80. JackSyncInterface* MakeInterProcessSync();
  81. JackThread* MakeThread(JackRunnableInterface* runnable);
  82. };
  83. #endif
  84. #ifdef WIN32
  85. class JackFactoryWindowsServer : public JackFactoryImpl
  86. {
  87. public:
  88. JackFactoryWindowsServer()
  89. {}
  90. virtual ~JackFactoryWindowsServer()
  91. {}
  92. JackSynchro* MakeSynchro();
  93. JackServerNotifyChannelInterface* MakeServerNotifyChannel();
  94. JackClientChannelInterface* MakeClientChannel();
  95. JackNotifyChannelInterface* MakeNotifyChannel();
  96. JackServerChannelInterface* MakeServerChannel();
  97. JackSyncInterface* MakeInterProcessSync();
  98. JackThread* MakeThread(JackRunnableInterface* runnable);
  99. };
  100. class JackFactoryWindowsClient : public JackFactoryImpl
  101. {
  102. public:
  103. JackFactoryWindowsClient()
  104. {}
  105. virtual ~JackFactoryWindowsClient()
  106. {}
  107. JackSynchro* MakeSynchro();
  108. JackServerNotifyChannelInterface* MakeServerNotifyChannel();
  109. JackClientChannelInterface* MakeClientChannel();
  110. JackNotifyChannelInterface* MakeNotifyChannel();
  111. JackServerChannelInterface* MakeServerChannel();
  112. JackSyncInterface* MakeInterProcessSync();
  113. JackThread* MakeThread(JackRunnableInterface* runnable);
  114. };
  115. #endif
  116. #if defined(__APPLE__)
  117. class JackFactoryOSXServer : public JackFactoryImpl
  118. {
  119. public:
  120. JackFactoryOSXServer()
  121. {}
  122. virtual ~JackFactoryOSXServer()
  123. {}
  124. JackSynchro* MakeSynchro();
  125. JackServerNotifyChannelInterface* MakeServerNotifyChannel();
  126. JackClientChannelInterface* MakeClientChannel();
  127. JackNotifyChannelInterface* MakeNotifyChannel();
  128. JackServerChannelInterface* MakeServerChannel();
  129. JackSyncInterface* MakeInterProcessSync();
  130. JackThread* MakeThread(JackRunnableInterface* runnable);
  131. };
  132. class JackFactoryOSXClient : public JackFactoryImpl
  133. {
  134. public:
  135. JackFactoryOSXClient()
  136. {}
  137. virtual ~JackFactoryOSXClient()
  138. {}
  139. JackSynchro* MakeSynchro();
  140. JackServerNotifyChannelInterface* MakeServerNotifyChannel();
  141. JackClientChannelInterface* MakeClientChannel();
  142. JackNotifyChannelInterface* MakeNotifyChannel();
  143. JackServerChannelInterface* MakeServerChannel();
  144. JackSyncInterface* MakeInterProcessSync();
  145. JackThread* MakeThread(JackRunnableInterface* runnable);
  146. };
  147. #endif
  148. /*!
  149. \brief Factory for OS specific ressources.
  150. */
  151. class JackGlobals
  152. {
  153. private:
  154. static JackFactoryImpl* fInstance;
  155. public:
  156. JackGlobals()
  157. {}
  158. virtual ~JackGlobals()
  159. {}
  160. static JackSynchro* MakeSynchro()
  161. {
  162. return fInstance->MakeSynchro();
  163. }
  164. static JackServerNotifyChannelInterface* MakeServerNotifyChannel()
  165. {
  166. return fInstance->MakeServerNotifyChannel();
  167. }
  168. static JackClientChannelInterface* MakeClientChannel()
  169. {
  170. return fInstance->MakeClientChannel();
  171. }
  172. static JackNotifyChannelInterface* MakeNotifyChannel()
  173. {
  174. return fInstance->MakeNotifyChannel();
  175. }
  176. static JackServerChannelInterface* MakeServerChannel()
  177. {
  178. return fInstance->MakeServerChannel();
  179. }
  180. static JackSyncInterface* MakeInterProcessSync()
  181. {
  182. return fInstance->MakeInterProcessSync();
  183. }
  184. static JackThread* MakeThread(JackRunnableInterface* runnable)
  185. {
  186. return fInstance->MakeThread(runnable);
  187. }
  188. static void InitServer();
  189. static void InitClient();
  190. static void Destroy();
  191. };
  192. namespace detail
  193. {
  194. struct JackGlobalsServerInitializer
  195. {
  196. JackGlobalsServerInitializer(void)
  197. {
  198. JackGlobals::InitServer();
  199. }
  200. ~JackGlobalsServerInitializer(void)
  201. {
  202. JackGlobals::Destroy();
  203. }
  204. };
  205. }
  206. } // end of namespace
  207. #ifdef __cplusplus
  208. extern "C"
  209. {
  210. #endif
  211. extern jack_tls_key gRealTime;
  212. extern jack_tls_key g_key_log_function;
  213. #ifdef WIN32
  214. EXPORT void jack_init();
  215. EXPORT void jack_uninit();
  216. #else
  217. void __attribute__ ((constructor)) jack_init();
  218. void __attribute__ ((destructor)) jack_uninit();
  219. #endif
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223. #endif