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.

113 lines
3.1KB

  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. #ifndef __JackPortAudioDriver__
  16. #define __JackPortAudioDriver__
  17. #include "JackAudioDriver.h"
  18. #include "JackPortAudioDevices.h"
  19. #ifdef _WIN32
  20. #include "JackMMCSS.h"
  21. #endif
  22. namespace Jack
  23. {
  24. /*!
  25. \brief The PortAudio driver.
  26. */
  27. class JackPortAudioDriver :
  28. #ifdef _WIN32
  29. public JackMMCSS,
  30. #endif
  31. public JackAudioDriver
  32. {
  33. private:
  34. PaStream* fStream;
  35. jack_default_audio_sample_t** fInputBuffer;
  36. jack_default_audio_sample_t** fOutputBuffer;
  37. PaDeviceIndex fInputDevice;
  38. PaDeviceIndex fOutputDevice;
  39. PortAudioDevices* fPaDevices;
  40. jack_native_thread_t fReservationLoopThread;
  41. static int Render(const void* inputBuffer, void* outputBuffer,
  42. unsigned long framesPerBuffer,
  43. const PaStreamCallbackTimeInfo* timeInfo,
  44. PaStreamCallbackFlags statusFlags,
  45. void* userData);
  46. PaError OpenStream(jack_nframes_t buffer_size);
  47. void UpdateLatencies();
  48. int Render(const void* inputBuffer, void* outputBuffer, PaStreamCallbackFlags statusFlags);
  49. public:
  50. JackPortAudioDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, PortAudioDevices* pa_devices) :
  51. #ifdef _WIN32
  52. JackMMCSS(),
  53. #endif
  54. JackAudioDriver(name, alias, engine, table), fStream(NULL), fInputBuffer(NULL), fOutputBuffer(NULL),
  55. fInputDevice(paNoDevice), fOutputDevice(paNoDevice), fPaDevices(pa_devices)
  56. {}
  57. virtual ~JackPortAudioDriver()
  58. {
  59. delete fPaDevices;
  60. }
  61. int Open(jack_nframes_t buffe_size,
  62. jack_nframes_t samplerate,
  63. bool capturing,
  64. bool playing,
  65. int chan_in,
  66. int chan_out,
  67. bool monitor,
  68. const char* capture_driver_name,
  69. const char* playback_driver_name,
  70. jack_nframes_t capture_latency,
  71. jack_nframes_t playback_latency);
  72. int Close();
  73. int Attach();
  74. int Start();
  75. int Stop();
  76. int Read();
  77. int Write();
  78. // BufferSize can be changed
  79. bool IsFixedBufferSize()
  80. {
  81. return false;
  82. }
  83. int SetBufferSize(jack_nframes_t buffer_size);
  84. };
  85. } // end of namespace
  86. #endif