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.

465 lines
11KB

  1. /*
  2. Copyright (C) 2004-2006 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. #ifdef WIN32
  16. #pragma warning (disable : 4786)
  17. #endif
  18. #include "JackGlobals.h"
  19. // OSX
  20. #if defined(__APPLE__)
  21. #include "JackCoreAudioDriver.h"
  22. #include "JackMachServerNotifyChannel.h"
  23. #include "JackMachNotifyChannel.h"
  24. #include "JackMachServerChannel.h"
  25. #include "JackMachClientChannel.h"
  26. #include "JackMachThread.h"
  27. #include "JackMachSemaphore.h"
  28. #include "JackProcessSync.h"
  29. #include "JackSocketServerNotifyChannel.h"
  30. #include "JackSocketNotifyChannel.h"
  31. #include "JackSocketServerChannel.h"
  32. #include "JackSocketClientChannel.h"
  33. #include "JackPosixThread.h"
  34. #include "JackPosixSemaphore.h"
  35. #include "JackFifo.h"
  36. #endif
  37. // WINDOWS
  38. #ifdef WIN32
  39. #include "JackWinProcessSync.h"
  40. #include "JackWinNamedPipeServerNotifyChannel.h"
  41. #include "JackWinNamedPipeNotifyChannel.h"
  42. #include "JackWinNamedPipeServerChannel.h"
  43. #include "JackWinNamedPipeClientChannel.h"
  44. #include "JackWinEvent.h"
  45. #include "JackWinThread.h"
  46. #endif
  47. // LINUX
  48. #ifdef __linux__
  49. #include "JackAlsaDriver.h"
  50. #include "JackProcessSync.h"
  51. #include "JackSocketServerNotifyChannel.h"
  52. #include "JackSocketNotifyChannel.h"
  53. #include "JackSocketServerChannel.h"
  54. #include "JackSocketClientChannel.h"
  55. #include "JackPosixThread.h"
  56. #include "JackPosixSemaphore.h"
  57. #include "JackFifo.h"
  58. #endif
  59. // COMMON
  60. #include "JackDummyDriver.h"
  61. #include "JackAudioDriver.h"
  62. using namespace std;
  63. namespace Jack
  64. {
  65. #ifdef WIN32
  66. JackSynchro* JackFactoryWindowsServer::MakeSynchro()
  67. {
  68. return new JackWinEvent();
  69. }
  70. JackServerNotifyChannelInterface* JackFactoryWindowsServer::MakeServerNotifyChannel()
  71. {
  72. return new JackWinNamedPipeServerNotifyChannel();
  73. }
  74. JackClientChannelInterface* JackFactoryWindowsServer::MakeClientChannel()
  75. {
  76. return NULL;
  77. } // Not used
  78. JackNotifyChannelInterface* JackFactoryWindowsServer::MakeNotifyChannel()
  79. {
  80. return new JackWinNamedPipeNotifyChannel();
  81. }
  82. JackServerChannelInterface* JackFactoryWindowsServer::MakeServerChannel()
  83. {
  84. return new JackWinNamedPipeServerChannel();
  85. }
  86. JackSyncInterface* JackFactoryWindowsServer::MakeInterProcessSync()
  87. {
  88. return new JackWinProcessSync();
  89. }
  90. JackThread* JackFactoryWindowsServer::MakeThread(JackRunnableInterface* runnable)
  91. {
  92. return new JackWinThread(runnable);
  93. }
  94. #endif
  95. #ifdef __linux__
  96. #if defined(SOCKET_RPC_POSIX_SEMA)
  97. JackSynchro* JackFactoryLinuxServer::MakeSynchro()
  98. {
  99. return new JackPosixSemaphore();
  100. }
  101. JackServerNotifyChannelInterface* JackFactoryLinuxServer::MakeServerNotifyChannel()
  102. {
  103. return new JackSocketServerNotifyChannel();
  104. }
  105. JackClientChannelInterface* JackFactoryLinuxServer::MakeClientChannel()
  106. {
  107. return NULL;
  108. } // Not used
  109. JackNotifyChannelInterface* JackFactoryLinuxServer::MakeNotifyChannel()
  110. {
  111. return new JackSocketNotifyChannel();
  112. }
  113. JackServerChannelInterface* JackFactoryLinuxServer::MakeServerChannel()
  114. {
  115. return new JackSocketServerChannel();
  116. }
  117. JackSyncInterface* JackFactoryLinuxServer::MakeInterProcessSync()
  118. {
  119. return new JackProcessSync();
  120. }
  121. JackThread* JackFactoryLinuxServer::MakeThread(JackRunnableInterface* runnable)
  122. {
  123. return new JackPosixThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  124. }
  125. #endif
  126. #if defined(SOCKET_RPC_FIFO_SEMA)
  127. JackSynchro* JackFactoryLinuxServer::MakeSynchro()
  128. {
  129. return new JackFifo();
  130. }
  131. JackServerNotifyChannelInterface* JackFactoryLinuxServer::MakeServerNotifyChannel()
  132. {
  133. return new JackSocketServerNotifyChannel();
  134. }
  135. JackClientChannelInterface* JackFactoryLinuxServer::MakeClientChannel()
  136. {
  137. return NULL;
  138. } // Not used
  139. JackNotifyChannelInterface* JackFactoryLinuxServer::MakeNotifyChannel()
  140. {
  141. return new JackSocketNotifyChannel();
  142. }
  143. JackServerChannelInterface* JackFactoryLinuxServer::MakeServerChannel()
  144. {
  145. return new JackSocketServerChannel();
  146. }
  147. JackSyncInterface* JackFactoryLinuxServer::MakeInterProcessSync()
  148. {
  149. return new JackProcessSync();
  150. }
  151. JackThread* JackFactoryLinuxServer::MakeThread(JackRunnableInterface* runnable)
  152. {
  153. return new JackPosixThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  154. }
  155. #endif
  156. #if defined(SOCKET_RPC_FIFO_SEMA_DUMMY)
  157. JackSynchro* JackFactoryLinuxServer::MakeSynchro()
  158. {
  159. return new JackFifo();
  160. }
  161. JackServerNotifyChannelInterface* JackFactoryLinuxServer::MakeServerNotifyChannel()
  162. {
  163. return new JackSocketServerNotifyChannel();
  164. }
  165. JackClientChannelInterface* JackFactoryLinuxServer::MakeClientChannel()
  166. {
  167. return NULL;
  168. } // Not used
  169. JackNotifyChannelInterface* JackFactoryLinuxServer::MakeNotifyChannel()
  170. {
  171. return new JackSocketNotifyChannel();
  172. }
  173. JackServerChannelInterface* JackFactoryLinuxServer::MakeServerChannel()
  174. {
  175. return new JackSocketServerChannel();
  176. }
  177. JackSyncInterface* JackFactoryLinuxServer::MakeInterProcessSync()
  178. {
  179. return new JackProcessSync();
  180. }
  181. JackThread* JackFactoryLinuxServer::MakeThread(JackRunnableInterface* runnable)
  182. {
  183. return new JackPosixThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  184. }
  185. #endif
  186. #endif
  187. #if defined(__APPLE__)
  188. #if defined(MACH_RPC_MACH_SEMA)
  189. // Mach RPC + Mach Semaphore
  190. JackSynchro* JackFactoryOSXServer::MakeSynchro()
  191. {
  192. return new JackMachSemaphore();
  193. }
  194. JackServerNotifyChannelInterface* JackFactoryOSXServer::MakeServerNotifyChannel()
  195. {
  196. return new JackMachServerNotifyChannel();
  197. }
  198. JackClientChannelInterface* JackFactoryOSXServer::MakeClientChannel()
  199. {
  200. return NULL;
  201. } // Not used
  202. JackNotifyChannelInterface* JackFactoryOSXServer::MakeNotifyChannel()
  203. {
  204. return new JackMachNotifyChannel();
  205. }
  206. JackServerChannelInterface* JackFactoryOSXServer::MakeServerChannel()
  207. {
  208. return new JackMachServerChannel();
  209. }
  210. JackSyncInterface* JackFactoryOSXServer::MakeInterProcessSync()
  211. {
  212. return new JackProcessSync();
  213. }
  214. JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable)
  215. {
  216. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  217. }
  218. #endif
  219. #if defined(SOCKET_RPC_POSIX_SEMA)
  220. // Socket RPC + Posix Semaphore
  221. JackSynchro* JackFactoryOSXServer::MakeSynchro()
  222. {
  223. return new JackPosixSemaphore();
  224. }
  225. JackServerNotifyChannelInterface* JackFactoryOSXServer::MakeServerNotifyChannel()
  226. {
  227. return new JackSocketServerNotifyChannel();
  228. }
  229. JackClientChannelInterface* JackFactoryOSXServer::MakeClientChannel()
  230. {
  231. return NULL;
  232. } // Not used
  233. JackNotifyChannelInterface* JackFactoryOSXServer::MakeNotifyChannel()
  234. {
  235. return new JackSocketNotifyChannel();
  236. }
  237. JackServerChannelInterface* JackFactoryOSXServer::MakeServerChannel()
  238. {
  239. return new JackSocketServerChannel();
  240. }
  241. JackSyncInterface* JackFactoryOSXServer::MakeInterProcessSync()
  242. {
  243. return new JackProcessSync();
  244. }
  245. JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable)
  246. {
  247. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  248. }
  249. #endif
  250. #if defined(SOCKET_RPC_FIFO_SEMA)
  251. // Socket RPC + Fifo Semaphore
  252. JackSynchro* JackFactoryOSXServer::MakeSynchro()
  253. {
  254. return new JackFifo();
  255. }
  256. JackServerNotifyChannelInterface* JackFactoryOSXServer::MakeServerNotifyChannel()
  257. {
  258. return new JackSocketServerNotifyChannel();
  259. }
  260. JackClientChannelInterface* JackFactoryOSXServer::MakeClientChannel()
  261. {
  262. return NULL;
  263. } // Not used
  264. JackNotifyChannelInterface* JackFactoryOSXServer::MakeNotifyChannel()
  265. {
  266. return new JackSocketNotifyChannel();
  267. }
  268. JackServerChannelInterface* JackFactoryOSXServer::MakeServerChannel()
  269. {
  270. return new JackSocketServerChannel();
  271. }
  272. JackSyncInterface* JackFactoryOSXServer::MakeInterProcessSync()
  273. {
  274. return new JackProcessSync();
  275. }
  276. JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable)
  277. {
  278. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  279. }
  280. #endif
  281. #if defined(MACH_RPC_FIFO_SEMA)
  282. // Mach RPC + Fifo Semaphore
  283. JackSynchro* JackFactoryOSXServer::MakeSynchro()
  284. {
  285. return new JackFifo();
  286. }
  287. JackServerNotifyChannelInterface* JackFactoryOSXServer::MakeServerNotifyChannel()
  288. {
  289. return new JackMachServerNotifyChannel();
  290. }
  291. JackClientChannelInterface* JackFactoryOSXServer::MakeClientChannel()
  292. {
  293. return NULL;
  294. } // Not used
  295. JackNotifyChannelInterface* JackFactoryOSXServer::MakeNotifyChannel()
  296. {
  297. return new JackMachNotifyChannel();
  298. }
  299. JackServerChannelInterface* JackFactoryOSXServer::MakeServerChannel()
  300. {
  301. return new JackMachServerChannel();
  302. }
  303. JackSyncInterface* JackFactoryOSXServer::MakeInterProcessSync()
  304. {
  305. return new JackProcessSync();
  306. }
  307. JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable)
  308. {
  309. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  310. }
  311. #endif
  312. #if defined(MACH_RPC_POSIX_SEMA)
  313. // Mach RPC + Posix Semaphore
  314. JackSynchro* JackFactoryOSXServer::MakeSynchro()
  315. {
  316. return new JackPosixSemaphore();
  317. }
  318. JackServerNotifyChannelInterface* JackFactoryOSXServer::MakeServerNotifyChannel()
  319. {
  320. return new JackMachServerNotifyChannel();
  321. }
  322. JackClientChannelInterface* JackFactoryOSXServer::MakeClientChannel()
  323. {
  324. return NULL;
  325. } // Not used
  326. JackNotifyChannelInterface* JackFactoryOSXServer::MakeNotifyChannel()
  327. {
  328. return new JackMachNotifyChannel();
  329. }
  330. JackServerChannelInterface* JackFactoryOSXServer::MakeServerChannel()
  331. {
  332. return new JackMachServerChannel();
  333. }
  334. JackSyncInterface* JackFactoryOSXServer::MakeInterProcessSync()
  335. {
  336. return new JackProcessSync();
  337. }
  338. JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable)
  339. {
  340. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  341. }
  342. #endif
  343. #if defined(SOCKET_RPC_MACH_SEMA)
  344. // Socket RPC + Mac Semaphore
  345. JackSynchro* JackFactoryOSXServer::MakeSynchro()
  346. {
  347. return new JackMachSemaphore();
  348. }
  349. JackServerNotifyChannelInterface* JackFactoryOSXServer::MakeServerNotifyChannel()
  350. {
  351. return new JackSocketServerNotifyChannel();
  352. }
  353. JackClientChannelInterface* JackFactoryOSXServer::MakeClientChannel()
  354. {
  355. return NULL;
  356. } // Not used
  357. JackNotifyChannelInterface* JackFactoryOSXServer::MakeNotifyChannel()
  358. {
  359. return new JackSocketNotifyChannel();
  360. }
  361. JackServerChannelInterface* JackFactoryOSXServer::MakeServerChannel()
  362. {
  363. return new JackSocketServerChannel();
  364. }
  365. JackSyncInterface* JackFactoryOSXServer::MakeInterProcessSync()
  366. {
  367. return new JackProcessSync();
  368. }
  369. JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable)
  370. {
  371. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  372. }
  373. #endif
  374. #endif
  375. } // end of namespace