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.

461 lines
10KB

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