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.

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