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.

482 lines
12KB

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