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.

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