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.

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