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

  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. int Render(const void* inputBuffer, void* outputBuffer, PaStreamCallbackFlags statusFlags);
  42. public:
  43. JackPortAudioDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, PortAudioDevices* pa_devices)
  44. : JackMMCSS(), JackAudioDriver(name, alias, engine, table), fStream(NULL), fInputBuffer(NULL), fOutputBuffer(NULL),
  45. fInputDevice(paNoDevice), fOutputDevice(paNoDevice), fPaDevices(pa_devices)
  46. {}
  47. virtual ~JackPortAudioDriver()
  48. {
  49. delete fPaDevices;
  50. }
  51. int Open(jack_nframes_t buffe_size,
  52. jack_nframes_t samplerate,
  53. bool capturing,
  54. bool playing,
  55. int chan_in,
  56. int chan_out,
  57. bool monitor,
  58. const char* capture_driver_name,
  59. const char* playback_driver_name,
  60. jack_nframes_t capture_latency,
  61. jack_nframes_t playback_latency);
  62. int Close();
  63. int Attach();
  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