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.

465 lines
11KB

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