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.

102 lines
3.4KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2008 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 __JackAudioDriver__
  17. #define __JackAudioDriver__
  18. #include "JackDriver.h"
  19. namespace Jack
  20. {
  21. /*!
  22. \brief The base class for audio drivers: drivers with audio ports.
  23. A concrete derived class will have to be defined with a real audio driver API,
  24. either callback based one (like CoreAudio, PortAudio..) ones or blocking ones (like ALSA).
  25. Most of the generic audio handing code is part of this class :
  26. - concrete callback basedd derived subclasses typically have to Open/Close the underlying audio API,
  27. setup the audio callback and implement the Read/Write methods
  28. - concrete blocking based derived subclasses typically have to Open/Close the underlying audio API,
  29. implement the Read/Write methods and "wraps" the driver with the JackThreadDriver class.
  30. */
  31. class SERVER_EXPORT JackAudioDriver : public JackDriver
  32. {
  33. protected:
  34. jack_default_audio_sample_t* GetInputBuffer(int port_index);
  35. jack_default_audio_sample_t* GetOutputBuffer(int port_index);
  36. jack_default_audio_sample_t* GetMonitorBuffer(int port_index);
  37. void HandleLatencyCallback(int status);
  38. virtual void UpdateLatencies();
  39. int ProcessAsync();
  40. void ProcessGraphAsync();
  41. void ProcessGraphAsyncMaster();
  42. void ProcessGraphAsyncSlave();
  43. int ProcessSync();
  44. void ProcessGraphSync();
  45. void ProcessGraphSyncMaster();
  46. void ProcessGraphSyncSlave();
  47. public:
  48. JackAudioDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
  49. virtual ~JackAudioDriver();
  50. virtual int Open(jack_nframes_t buffer_size,
  51. jack_nframes_t samplerate,
  52. bool capturing,
  53. bool playing,
  54. int inchannels,
  55. int outchannels,
  56. bool monitor,
  57. const char* capture_driver_name,
  58. const char* playback_driver_name,
  59. jack_nframes_t capture_latency,
  60. jack_nframes_t playback_latency);
  61. /*
  62. To be called by the underlying driver audio callback, or possibly by a RT thread (using JackThreadedDriver decorator)
  63. when a blocking read/write underlying API is used (like ALSA)
  64. */
  65. virtual int Process();
  66. virtual int Attach();
  67. virtual int Detach();
  68. virtual int Write();
  69. virtual int SetBufferSize(jack_nframes_t buffer_size);
  70. virtual int SetSampleRate(jack_nframes_t sample_rate);
  71. virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
  72. };
  73. } // end of namespace
  74. #endif