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.

458 lines
10KB

  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 Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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. #endif
  293. #if defined(MACH_RPC_FIFO_SEMA)
  294. // Mach RPC + Fifo Semaphore
  295. JackSynchro* JackFactoryOSXClient::MakeSynchro()
  296. {
  297. return new JackFifo();
  298. }
  299. JackServerNotifyChannelInterface* JackFactoryOSXClient::MakeServerNotifyChannel()
  300. {
  301. return NULL;
  302. }
  303. // Not used
  304. JackClientChannelInterface* JackFactoryOSXClient::MakeClientChannel()
  305. {
  306. return new JackMachClientChannel();
  307. }
  308. JackNotifyChannelInterface* JackFactoryOSXClient::MakeNotifyChannel()
  309. {
  310. return NULL;
  311. }
  312. // Not used
  313. JackServerChannelInterface* JackFactoryOSXClient::MakeServerChannel()
  314. {
  315. return NULL;
  316. }
  317. // Not used
  318. JackSyncInterface* JackFactoryOSXClient::MakeInterProcessSync()
  319. {
  320. return new JackProcessSync();
  321. }
  322. JackThread* JackFactoryOSXClient::MakeThread(JackRunnableInterface* runnable)
  323. {
  324. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  325. }
  326. #endif
  327. #if defined(MACH_RPC_POSIX_SEMA)
  328. // Mach RPC + Posix Semaphore
  329. JackSynchro* JackFactoryOSXClient::MakeSynchro()
  330. {
  331. return new JackPosixSemaphore();
  332. }
  333. JackServerNotifyChannelInterface* JackFactoryOSXClient::MakeServerNotifyChannel()
  334. {
  335. return NULL;
  336. }
  337. // Not used
  338. JackClientChannelInterface* JackFactoryOSXClient::MakeClientChannel()
  339. {
  340. return new JackMachClientChannel();
  341. }
  342. JackNotifyChannelInterface* JackFactoryOSXClient::MakeNotifyChannel()
  343. {
  344. return NULL;
  345. }
  346. // Not used
  347. JackServerChannelInterface* JackFactoryOSXClient::MakeServerChannel()
  348. {
  349. return NULL;
  350. }
  351. // Not used
  352. JackSyncInterface* JackFactoryOSXClient::MakeInterProcessSync()
  353. {
  354. return new JackProcessSync();
  355. }
  356. JackThread* JackFactoryOSXClient::MakeThread(JackRunnableInterface* runnable)
  357. {
  358. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  359. }
  360. #endif
  361. #if defined SOCKET_RPC_MACH_SEMA
  362. // Socket RPC + Mach Semaphore
  363. JackSynchro* JackFactoryOSXClient::MakeSynchro()
  364. {
  365. return new JackMachSemaphore();
  366. }
  367. JackServerNotifyChannelInterface* JackFactoryOSXClient::MakeServerNotifyChannel()
  368. {
  369. return NULL;
  370. }
  371. // Not used
  372. JackClientChannelInterface* JackFactoryOSXClient::MakeClientChannel()
  373. {
  374. return new JackSocketClientChannel();
  375. }
  376. JackNotifyChannelInterface* JackFactoryOSXClient::MakeNotifyChannel()
  377. {
  378. return NULL;
  379. }
  380. // Not used
  381. JackServerChannelInterface* JackFactoryOSXClient::MakeServerChannel()
  382. {
  383. return NULL;
  384. }
  385. // Not used
  386. JackSyncInterface* JackFactoryOSXClient::MakeInterProcessSync()
  387. {
  388. return new JackProcessSync();
  389. }
  390. JackThread* JackFactoryOSXClient::MakeThread(JackRunnableInterface* runnable)
  391. {
  392. return new JackMachThread(runnable, PTHREAD_CANCEL_ASYNCHRONOUS);
  393. }
  394. #endif
  395. #endif
  396. } // end of namespace