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.

90 lines
2.7KB

  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 "portaudio.h"
  19. namespace Jack
  20. {
  21. /*!
  22. \brief The PortAudio driver.
  23. */
  24. class JackPortAudioDriver : public JackAudioDriver
  25. {
  26. private:
  27. PaStream* fStream;
  28. float** fInputBuffer;
  29. float** fOutputBuffer;
  30. PaDeviceIndex fInputDevice;
  31. PaDeviceIndex fOutputDevice;
  32. void PrintSupportedStandardSampleRates(const PaStreamParameters* inputParameters, const PaStreamParameters* outputParameters);
  33. bool GetInputDeviceFromName(const char* name, PaDeviceIndex* device, int* in_max);
  34. bool GetOutputDeviceFromName(const char* name, PaDeviceIndex* device, int* out_max);
  35. static int Render(const void* inputBuffer, void* outputBuffer,
  36. unsigned long framesPerBuffer,
  37. const PaStreamCallbackTimeInfo* timeInfo,
  38. PaStreamCallbackFlags statusFlags,
  39. void* userData);
  40. public:
  41. JackPortAudioDriver(const char* name, const char* alias, JackEngineInterface* engine, JackSynchro* table)
  42. : JackAudioDriver(name, alias, engine, table), fStream(NULL), fInputBuffer(NULL), fOutputBuffer(NULL),
  43. fInputDevice(paNoDevice), fOutputDevice(paNoDevice)
  44. {}
  45. virtual ~JackPortAudioDriver()
  46. {}
  47. int Open(jack_nframes_t frames_per_cycle,
  48. jack_nframes_t rate,
  49. bool capturing,
  50. bool playing,
  51. int chan_in,
  52. int chan_out,
  53. bool monitor,
  54. const char* capture_driver_name,
  55. const char* playback_driver_name,
  56. jack_nframes_t capture_latency,
  57. jack_nframes_t playback_latency);
  58. int Close();
  59. int Start();
  60. int Stop();
  61. int Read();
  62. int Write();
  63. int SetBufferSize(jack_nframes_t buffer_size);
  64. };
  65. } // end of namespace
  66. #endif