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.

101 lines
2.8KB

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