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.

196 lines
5.7KB

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