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.

86 lines
2.2KB

  1. /*
  2. Copyright (C) 2009 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 __JackAudioQueueAdapter__
  16. #define __JackAudioQueueAdapter__
  17. #include <AudioToolbox/AudioConverter.h>
  18. #include <AudioToolbox/AudioQueue.h>
  19. #include <jack/net.h>
  20. namespace Jack
  21. {
  22. /*!
  23. \brief Audio adapter using AudioQueue API.
  24. */
  25. static const int kNumberBuffers = 3;
  26. class JackAudioQueueAdapter
  27. {
  28. private:
  29. AudioQueueRef fCaptureQueue;
  30. AudioQueueBufferRef fCaptureQueueBuffers[kNumberBuffers];
  31. AudioQueueRef fPlaybackQueue;
  32. AudioQueueBufferRef fPlaybackQueueBuffers[kNumberBuffers];
  33. AudioStreamPacketDescription fPlaybackPacketDescs;
  34. jack_nframes_t fBufferSize;
  35. jack_nframes_t fSampleRate;
  36. int fCaptureChannels;
  37. int fPlaybackChannels;
  38. jack_adapter_t* fAdapter;
  39. static void CaptureCallback(void * inUserData,
  40. AudioQueueRef inAQ,
  41. AudioQueueBufferRef inBuffer,
  42. const AudioTimeStamp * inStartTime,
  43. UInt32 inNumPackets,
  44. const AudioStreamPacketDescription *inPacketDesc);
  45. static void PlaybackCallback(void * inUserData,
  46. AudioQueueRef inAQ,
  47. AudioQueueBufferRef inCompleteAQBuffer);
  48. public:
  49. JackAudioQueueAdapter(int inchan, int outchan, jack_nframes_t buffer_size, jack_nframes_t sample_rate, jack_adapter_t* adapter);
  50. ~JackAudioQueueAdapter();
  51. virtual int Open();
  52. virtual int Close();
  53. virtual int SetSampleRate(jack_nframes_t sample_rate);
  54. virtual int SetBufferSize(jack_nframes_t buffer_size);
  55. };
  56. }
  57. #endif