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.

127 lines
4.3KB

  1. /*
  2. Copyright (C) 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 __JackCoreAudioAdapter__
  16. #define __JackCoreAudioAdapter__
  17. #include "JackAudioAdapterInterface.h"
  18. #include "jack.h"
  19. #include "jslist.h"
  20. #include <AudioToolbox/AudioConverter.h>
  21. #include <CoreAudio/CoreAudio.h>
  22. #include <AudioUnit/AudioUnit.h>
  23. namespace Jack
  24. {
  25. typedef UInt8 CAAudioHardwareDeviceSectionID;
  26. #define kAudioDeviceSectionInput ((CAAudioHardwareDeviceSectionID)0x01)
  27. #define kAudioDeviceSectionOutput ((CAAudioHardwareDeviceSectionID)0x00)
  28. #define kAudioDeviceSectionGlobal ((CAAudioHardwareDeviceSectionID)0x00)
  29. #define kAudioDeviceSectionWildcard ((CAAudioHardwareDeviceSectionID)0xFF)
  30. class JackCoreAudioAdapter : public JackAudioAdapterInterface
  31. {
  32. private:
  33. AudioUnit fAUHAL;
  34. AudioBufferList* fInputData;
  35. AudioDeviceID fDeviceID;
  36. bool fState;
  37. AudioUnitRenderActionFlags* fActionFags;
  38. AudioTimeStamp* fCurrentTime;
  39. static OSStatus Render(void *inRefCon,
  40. AudioUnitRenderActionFlags *ioActionFlags,
  41. const AudioTimeStamp *inTimeStamp,
  42. UInt32 inBusNumber,
  43. UInt32 inNumberFrames,
  44. AudioBufferList *ioData);
  45. static OSStatus SRNotificationCallback(AudioDeviceID inDevice,
  46. UInt32 inChannel,
  47. Boolean isInput,
  48. AudioDevicePropertyID inPropertyID,
  49. void* inClientData);
  50. OSStatus GetDefaultDevice(AudioDeviceID* id);
  51. OSStatus GetTotalChannels(AudioDeviceID device, int* channelCount, bool isInput);
  52. // Setup
  53. int SetupDevices(const char* capture_driver_uid,
  54. const char* playback_driver_uid,
  55. char* capture_driver_name,
  56. char* playback_driver_name);
  57. int SetupChannels(bool capturing,
  58. bool playing,
  59. int& inchannels,
  60. int& outchannels,
  61. int& in_nChannels,
  62. int& out_nChannels,
  63. bool strict);
  64. int OpenAUHAL(bool capturing,
  65. bool playing,
  66. int inchannels,
  67. int outchannels,
  68. int in_nChannels,
  69. int out_nChannels,
  70. jack_nframes_t buffer_size,
  71. jack_nframes_t samplerate,
  72. bool strict);
  73. int SetupBufferSizeAndSampleRate(jack_nframes_t buffer_size, jack_nframes_t samplerate);
  74. int SetupBuffers(int inchannels, int outchannels);
  75. void DisposeBuffers();
  76. void CloseAUHAL();
  77. public:
  78. JackCoreAudioAdapter( jack_nframes_t buffer_size, jack_nframes_t sample_rate, const JSList* params);
  79. ~JackCoreAudioAdapter()
  80. {}
  81. virtual int Open();
  82. virtual int Close();
  83. virtual int SetBufferSize(jack_nframes_t buffer_size);
  84. };
  85. }
  86. #ifdef __cplusplus
  87. extern "C"
  88. {
  89. #endif
  90. #include "JackExports.h"
  91. #include "driver_interface.h"
  92. EXPORT jack_driver_desc_t* jack_get_descriptor();
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif