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.

95 lines
3.2KB

  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 __JackCoreAudioIOAdapter__
  16. #define __JackCoreAudioIOAdapter__
  17. #include "JackIOAdapter.h"
  18. #include "jack.h"
  19. #include <AudioToolbox/AudioConverter.h>
  20. #include <CoreAudio/CoreAudio.h>
  21. #include <AudioUnit/AudioUnit.h>
  22. namespace Jack
  23. {
  24. typedef UInt8 CAAudioHardwareDeviceSectionID;
  25. #define kAudioDeviceSectionInput ((CAAudioHardwareDeviceSectionID)0x01)
  26. #define kAudioDeviceSectionOutput ((CAAudioHardwareDeviceSectionID)0x00)
  27. #define kAudioDeviceSectionGlobal ((CAAudioHardwareDeviceSectionID)0x00)
  28. #define kAudioDeviceSectionWildcard ((CAAudioHardwareDeviceSectionID)0xFF)
  29. class JackCoreAudioIOAdapter : public JackIOAdapterInterface
  30. {
  31. private:
  32. AudioUnit fAUHAL;
  33. AudioDeviceID fDeviceID;
  34. AudioUnitRenderActionFlags* fActionFags;
  35. AudioTimeStamp* fCurrentTime;
  36. static OSStatus Render(void *inRefCon,
  37. AudioUnitRenderActionFlags *ioActionFlags,
  38. const AudioTimeStamp *inTimeStamp,
  39. UInt32 inBusNumber,
  40. UInt32 inNumberFrames,
  41. AudioBufferList *ioData);
  42. OSStatus GetDeviceIDFromUID(const char* UID, AudioDeviceID* id);
  43. OSStatus GetDefaultDevice(AudioDeviceID* id);
  44. OSStatus GetDefaultInputDevice(AudioDeviceID* id);
  45. OSStatus GetDefaultOutputDevice(AudioDeviceID* id);
  46. OSStatus GetDeviceNameFromID(AudioDeviceID id, char* name);
  47. OSStatus GetTotalChannels(AudioDeviceID device, int* channelCount, bool isInput);
  48. // Setup
  49. int SetupDevices(const char* capture_driver_uid,
  50. const char* playback_driver_uid,
  51. char* capture_driver_name,
  52. char* playback_driver_name);
  53. int SetupChannels(bool capturing,
  54. bool playing,
  55. int& inchannels,
  56. int& outchannels,
  57. int& in_nChannels,
  58. int& out_nChannels,
  59. bool strict);
  60. int SetupBufferSizeAndSampleRate(jack_nframes_t nframes, jack_nframes_t samplerate);
  61. public:
  62. JackCoreAudioIOAdapter(int input, int output)
  63. :JackIOAdapterInterface(input, output)
  64. {}
  65. ~JackCoreAudioIOAdapter()
  66. {}
  67. };
  68. }
  69. #endif