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
5.1KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2006 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #ifndef __JackDriver__
  17. #define __JackDriver__
  18. #include "types.h"
  19. #include "JackClientInterface.h"
  20. #include "JackConstants.h"
  21. #include <list>
  22. namespace Jack
  23. {
  24. class JackEngine;
  25. class JackGraphManager;
  26. class JackSynchro;
  27. struct JackEngineControl;
  28. struct JackClientControl;
  29. /*!
  30. \brief The base interface for drivers.
  31. */
  32. class EXPORT JackDriverInterface
  33. {
  34. public:
  35. JackDriverInterface()
  36. {}
  37. virtual ~JackDriverInterface()
  38. {}
  39. virtual int Open() = 0;
  40. virtual int Open(jack_nframes_t nframes,
  41. jack_nframes_t samplerate,
  42. int capturing,
  43. int playing,
  44. int inchannels,
  45. int outchannels,
  46. bool monitor,
  47. const char* capture_driver_name,
  48. const char* playback_driver_name,
  49. jack_nframes_t capture_latency,
  50. jack_nframes_t playback_latency) = 0;
  51. virtual int Attach() = 0;
  52. virtual int Detach() = 0;
  53. virtual int Read() = 0;
  54. virtual int Write() = 0;
  55. virtual int Start() = 0;
  56. virtual int Stop() = 0;
  57. virtual int SetBufferSize(jack_nframes_t buffer_size) = 0;
  58. virtual int Process() = 0;
  59. virtual void SetMaster(bool onoff) = 0;
  60. virtual bool GetMaster() = 0;
  61. virtual void AddSlave(JackDriverInterface* slave) = 0;
  62. virtual void RemoveSlave(JackDriverInterface* slave) = 0;
  63. virtual int ProcessSlaves() = 0;
  64. virtual bool IsRealTime() = 0;
  65. };
  66. /*!
  67. \brief The base interface for drivers clients.
  68. */
  69. class EXPORT JackDriverClientInterface : public JackDriverInterface, public JackClientInterface
  70. {};
  71. /*!
  72. \brief The base class for drivers clients.
  73. */
  74. class EXPORT JackDriverClient : public JackDriverClientInterface
  75. {
  76. private:
  77. std::list<JackDriverInterface*> fSlaveList;
  78. protected:
  79. bool fIsMaster;
  80. public:
  81. virtual void SetMaster(bool onoff);
  82. virtual bool GetMaster();
  83. virtual void AddSlave(JackDriverInterface* slave);
  84. virtual void RemoveSlave(JackDriverInterface* slave);
  85. virtual int ProcessSlaves();
  86. };
  87. /*!
  88. \brief The base class for drivers.
  89. */
  90. class EXPORT JackDriver : public JackDriverClient
  91. {
  92. protected:
  93. char fCaptureDriverName[JACK_CLIENT_NAME_SIZE];
  94. char fPlaybackDriverName[JACK_CLIENT_NAME_SIZE];
  95. jack_nframes_t fCaptureLatency;
  96. jack_nframes_t fPlaybackLatency;
  97. jack_time_t fLastWaitUst;
  98. JackEngine* fEngine;
  99. JackGraphManager* fGraphManager;
  100. JackSynchro** fSynchroTable;
  101. JackEngineControl* fEngineControl;
  102. JackClientControl* fClientControl;
  103. JackClientControl* GetClientControl() const;
  104. public:
  105. JackDriver(const char* name, JackEngine* engine, JackSynchro** table);
  106. JackDriver();
  107. virtual ~JackDriver();
  108. virtual int Open();
  109. virtual int Open(jack_nframes_t nframes,
  110. jack_nframes_t samplerate,
  111. int capturing,
  112. int playing,
  113. int inchannels,
  114. int outchannels,
  115. bool monitor,
  116. const char* capture_driver_name,
  117. const char* playback_driver_name,
  118. jack_nframes_t capture_latency,
  119. jack_nframes_t playback_latency);
  120. virtual int Close();
  121. virtual int Process()
  122. {
  123. return 0;
  124. }
  125. virtual int Attach()
  126. {
  127. return 0;
  128. }
  129. virtual int Detach()
  130. {
  131. return 0;
  132. }
  133. virtual int Read()
  134. {
  135. return 0;
  136. }
  137. virtual int Write()
  138. {
  139. return 0;
  140. }
  141. virtual int Start()
  142. {
  143. return 0;
  144. }
  145. virtual int Stop()
  146. {
  147. return 0;
  148. }
  149. virtual int SetBufferSize(jack_nframes_t buffer_size)
  150. {
  151. return 0;
  152. }
  153. void NotifyXRun(jack_time_t callback_usecs); // XRun notification sent by the driver
  154. virtual bool IsRealTime();
  155. int ClientNotify(int refnum, const char* name, int notify, int sync, int value)
  156. {
  157. return 0;
  158. }
  159. };
  160. } // end of namespace
  161. #endif