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.

212 lines
6.2KB

  1. /*
  2. Copyright (C) 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. #ifndef __JackLockedEngine__
  16. #define __JackLockedEngine__
  17. #include "JackEngine.h"
  18. #include "JackMutex.h"
  19. namespace Jack
  20. {
  21. /*!
  22. \brief Locked Engine.
  23. */
  24. class JackLockedEngine : public JackEngine, public JackLockAble
  25. {
  26. private:
  27. JackEngine* fEngine;
  28. public:
  29. JackLockedEngine(JackEngine* engine):fEngine(engine)
  30. {}
  31. virtual ~JackLockedEngine()
  32. {
  33. delete fEngine;
  34. }
  35. int Open()
  36. {
  37. // No lock needed
  38. return fEngine->Open();
  39. }
  40. int Close()
  41. {
  42. // No lock needed
  43. return fEngine->Close();
  44. }
  45. // Client management
  46. int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status)
  47. {
  48. JackLock lock(this);
  49. return fEngine->ClientCheck(name, name_res, protocol, options, status);
  50. }
  51. int ClientExternalOpen(const char* name, int pid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager)
  52. {
  53. JackLock lock(this);
  54. return fEngine->ClientExternalOpen(name, pid, ref, shared_engine, shared_client, shared_graph_manager);
  55. }
  56. int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait)
  57. {
  58. JackLock lock(this);
  59. return fEngine->ClientInternalOpen(name, ref, shared_engine, shared_manager, client, wait);
  60. }
  61. int ClientExternalClose(int refnum)
  62. {
  63. JackLock lock(this);
  64. return fEngine->ClientExternalClose(refnum);
  65. }
  66. int ClientInternalClose(int refnum, bool wait)
  67. {
  68. JackLock lock(this);
  69. return fEngine->ClientInternalClose(refnum, wait);
  70. }
  71. int ClientActivate(int refnum, bool state)
  72. {
  73. JackLock lock(this);
  74. return fEngine->ClientActivate(refnum, state);
  75. }
  76. int ClientDeactivate(int refnum)
  77. {
  78. JackLock lock(this);
  79. return fEngine->ClientDeactivate(refnum);
  80. }
  81. // Internal client management
  82. int GetInternalClientName(int int_ref, char* name_res)
  83. {
  84. JackLock lock(this);
  85. return fEngine->GetInternalClientName(int_ref, name_res);
  86. }
  87. int InternalClientHandle(const char* client_name, int* status, int* int_ref)
  88. {
  89. JackLock lock(this);
  90. return fEngine->InternalClientHandle(client_name, status, int_ref);
  91. }
  92. int InternalClientUnload(int refnum, int* status)
  93. {
  94. JackLock lock(this);
  95. return fEngine->InternalClientUnload(refnum, status);
  96. }
  97. // Port management
  98. int PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, unsigned int* port)
  99. {
  100. JackLock lock(this);
  101. return fEngine->PortRegister(refnum, name, type, flags, buffer_size, port);
  102. }
  103. int PortUnRegister(int refnum, jack_port_id_t port)
  104. {
  105. JackLock lock(this);
  106. return fEngine->PortUnRegister(refnum, port);
  107. }
  108. int PortConnect(int refnum, const char* src, const char* dst)
  109. {
  110. JackLock lock(this);
  111. return fEngine->PortConnect(refnum, src, dst);
  112. }
  113. int PortDisconnect(int refnum, const char* src, const char* dst)
  114. {
  115. JackLock lock(this);
  116. return fEngine->PortDisconnect(refnum, src, dst);
  117. }
  118. int PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
  119. {
  120. JackLock lock(this);
  121. return fEngine->PortConnect(refnum, src, dst);
  122. }
  123. int PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
  124. {
  125. JackLock lock(this);
  126. return fEngine->PortDisconnect(refnum, src, dst);
  127. }
  128. // Graph
  129. bool Process(jack_time_t callback_usecs)
  130. {
  131. // RT : no lock
  132. return fEngine->Process(callback_usecs);
  133. }
  134. // Notifications
  135. void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs)
  136. {
  137. // RT : no lock
  138. fEngine->NotifyXRun(callback_usecs, delayed_usecs);
  139. }
  140. void NotifyXRun(int refnum)
  141. {
  142. JackLock lock(this);
  143. fEngine->NotifyXRun(refnum);
  144. }
  145. void NotifyGraphReorder()
  146. {
  147. JackLock lock(this);
  148. fEngine->NotifyGraphReorder();
  149. }
  150. void NotifyBufferSize(jack_nframes_t nframes)
  151. {
  152. JackLock lock(this);
  153. fEngine->NotifyBufferSize(nframes);
  154. }
  155. void NotifyFreewheel(bool onoff)
  156. {
  157. JackLock lock(this);
  158. fEngine->NotifyFreewheel(onoff);
  159. }
  160. void NotifyPortRegistation(jack_port_id_t port_index, bool onoff)
  161. {
  162. JackLock lock(this);
  163. fEngine->NotifyPortRegistation(port_index, onoff);
  164. }
  165. void NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff)
  166. {
  167. JackLock lock(this);
  168. fEngine->NotifyPortConnect(src, dst, onoff);
  169. }
  170. void NotifyActivate(int refnum)
  171. {
  172. JackLock lock(this);
  173. fEngine->NotifyActivate(refnum);
  174. }
  175. int GetClientPID(const char* name)
  176. {
  177. JackLock lock(this);
  178. return fEngine->GetClientPID(name);
  179. }
  180. };
  181. } // end of namespace
  182. #endif