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.

493 lines
13KB

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