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.

126 lines
3.7KB

  1. /*
  2. Copyright (C) 2004-2006 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 __JackCoreAudioDriver__
  16. #define __JackCoreAudioDriver__
  17. #include <AudioToolbox/AudioConverter.h>
  18. #include <CoreAudio/CoreAudio.h>
  19. #include <AudioUnit/AudioUnit.h>
  20. #include "JackAudioDriver.h"
  21. #include "JackTime.h"
  22. #include "/Developer/Examples/CoreAudio/PublicUtility/CALatencyLog.h"
  23. namespace Jack
  24. {
  25. #define kVersion 102
  26. #define LOG_SAMPLE_DURATION 3 // in millisecond
  27. //#define IO_CPU 1
  28. /*!
  29. \brief The CoreAudio driver.
  30. \todo hardware monitoring
  31. */
  32. class JackCoreAudioDriver : public JackAudioDriver
  33. {
  34. private:
  35. #ifdef DEBUG
  36. //CALatencyLog* fLogFile;
  37. #endif
  38. AudioUnit fAUHAL;
  39. AudioBufferList* fJackInputData;
  40. AudioBufferList* fDriverOutputData;
  41. AudioDeviceID fDeviceID;
  42. AudioUnitRenderActionFlags fActionFags;
  43. AudioTimeStamp fCurrentTime;
  44. static OSStatus Render(void *inRefCon,
  45. AudioUnitRenderActionFlags *ioActionFlags,
  46. const AudioTimeStamp *inTimeStamp,
  47. UInt32 inBusNumber,
  48. UInt32 inNumberFrames,
  49. AudioBufferList *ioData);
  50. static OSStatus MeasureCallback(AudioDeviceID inDevice,
  51. const AudioTimeStamp* inNow,
  52. const AudioBufferList* inInputData,
  53. const AudioTimeStamp* inInputTime,
  54. AudioBufferList* outOutputData,
  55. const AudioTimeStamp* inOutputTime,
  56. void* inClientData);
  57. static OSStatus DeviceNotificationCallback(AudioDeviceID inDevice,
  58. UInt32 inChannel,
  59. Boolean isInput,
  60. AudioDevicePropertyID inPropertyID,
  61. void* inClientData);
  62. OSStatus GetDeviceIDFromUID(const char* UID, AudioDeviceID* id);
  63. OSStatus GetDefaultDevice(AudioDeviceID* id);
  64. OSStatus GetDefaultInputDevice(AudioDeviceID* id);
  65. OSStatus GetDefaultOutputDevice(AudioDeviceID* id);
  66. OSStatus GetDeviceNameFromID(AudioDeviceID id, char* name);
  67. OSStatus GetTotalChannels(AudioDeviceID device, long* channelCount, bool isInput);
  68. public:
  69. JackCoreAudioDriver(const char* name, JackEngine* engine, JackSynchro** table);
  70. virtual ~JackCoreAudioDriver();
  71. int Open(jack_nframes_t frames_per_cycle,
  72. jack_nframes_t rate,
  73. int capturing,
  74. int playing,
  75. int chan_in,
  76. int chan_out,
  77. bool monitor,
  78. const char* capture_driver_name,
  79. const char* playback_driver_name,
  80. jack_nframes_t capture_latency,
  81. jack_nframes_t playback_latency);
  82. int Close();
  83. int Attach();
  84. int Start();
  85. int Stop();
  86. int Read();
  87. int Write();
  88. int SetBufferSize(jack_nframes_t buffer_size);
  89. void PrintState();
  90. };
  91. } // end of namespace
  92. #endif