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"
29 #include "/Developer/Examples/CoreAudio/PublicUtility/CALatencyLog.h"
35 #define LOG_SAMPLE_DURATION 3 // in millisecond
40 \brief The CoreAudio driver.
42 \todo hardware monitoring
45 class JackCoreAudioDriver
: public JackAudioDriver
50 //CALatencyLog* fLogFile;
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
,
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
,
78 static OSStatus
DeviceNotificationCallback(AudioDeviceID inDevice
,
81 AudioDevicePropertyID inPropertyID
,
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
);
93 JackCoreAudioDriver(const char* name
, JackEngine
* engine
, JackSynchro
** table
);
94 virtual ~JackCoreAudioDriver();
96 int Open(jack_nframes_t frames_per_cycle
,
103 const char* capture_driver_name
,
104 const char* playback_driver_name
,
105 jack_nframes_t capture_latency
,
106 jack_nframes_t playback_latency
);
118 int SetBufferSize(jack_nframes_t buffer_size
);
123 } // end of namespace