Memory locking tools
[jack2.git] / macosx / JackCoreAudioDriver.h
blob8c3a3dfb98c2686780540adccd3f9ccdb49fc3f4
1 /*
2 Copyright (C) 2004-2006 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __JackCoreAudioDriver__
21 #define __JackCoreAudioDriver__
23 #include <AudioToolbox/AudioConverter.h>
24 #include <CoreAudio/CoreAudio.h>
25 #include <AudioUnit/AudioUnit.h>
26 #include "JackAudioDriver.h"
27 #include "JackTime.h"
29 #include "/Developer/Examples/CoreAudio/PublicUtility/CALatencyLog.h"
31 namespace Jack
34 #define kVersion 102
35 #define LOG_SAMPLE_DURATION 3 // in millisecond
37 //#define IO_CPU 1
39 /*!
40 \brief The CoreAudio driver.
42 \todo hardware monitoring
45 class JackCoreAudioDriver : public JackAudioDriver
48 private:
49 #ifdef DEBUG
50 //CALatencyLog* fLogFile;
51 #endif
53 AudioUnit fAUHAL;
55 AudioBufferList* fJackInputData;
56 AudioBufferList* fDriverOutputData;
58 AudioDeviceID fDeviceID;
60 AudioUnitRenderActionFlags fActionFags;
61 AudioTimeStamp fCurrentTime;
63 static OSStatus Render(void *inRefCon,
64 AudioUnitRenderActionFlags *ioActionFlags,
65 const AudioTimeStamp *inTimeStamp,
66 UInt32 inBusNumber,
67 UInt32 inNumberFrames,
68 AudioBufferList *ioData);
70 static OSStatus MeasureCallback(AudioDeviceID inDevice,
71 const AudioTimeStamp* inNow,
72 const AudioBufferList* inInputData,
73 const AudioTimeStamp* inInputTime,
74 AudioBufferList* outOutputData,
75 const AudioTimeStamp* inOutputTime,
76 void* inClientData);
78 static OSStatus DeviceNotificationCallback(AudioDeviceID inDevice,
79 UInt32 inChannel,
80 Boolean isInput,
81 AudioDevicePropertyID inPropertyID,
82 void* inClientData);
84 OSStatus GetDeviceIDFromUID(const char* UID, AudioDeviceID* id);
85 OSStatus GetDefaultDevice(AudioDeviceID* id);
86 OSStatus GetDefaultInputDevice(AudioDeviceID* id);
87 OSStatus GetDefaultOutputDevice(AudioDeviceID* id);
88 OSStatus GetDeviceNameFromID(AudioDeviceID id, char* name);
89 OSStatus GetTotalChannels(AudioDeviceID device, long* channelCount, bool isInput);
91 public:
93 JackCoreAudioDriver(const char* name, JackEngine* engine, JackSynchro** table);
94 virtual ~JackCoreAudioDriver();
96 int Open(jack_nframes_t frames_per_cycle,
97 jack_nframes_t rate,
98 int capturing,
99 int playing,
100 int chan_in,
101 int chan_out,
102 bool monitor,
103 const char* capture_driver_name,
104 const char* playback_driver_name,
105 jack_nframes_t capture_latency,
106 jack_nframes_t playback_latency);
108 int Close();
110 int Attach();
112 int Start();
113 int Stop();
115 int Read();
116 int Write();
118 int SetBufferSize(jack_nframes_t buffer_size);
120 void PrintState();
123 } // end of namespace
125 #endif