JackCoreAudioDriver.h

00001 /*
00002 Copyright (C) 2004-2006 Grame
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 
00018 */
00019 
00020 #ifndef __JackCoreAudioDriver__
00021 #define __JackCoreAudioDriver__
00022 
00023 #include <AudioToolbox/AudioConverter.h>
00024 #include <CoreAudio/CoreAudio.h>
00025 #include <AudioUnit/AudioUnit.h>
00026 #include "JackAudioDriver.h"
00027 #include "JackTime.h"
00028 
00029 #include "/Developer/Examples/CoreAudio/PublicUtility/CALatencyLog.h"
00030 
00031 namespace Jack
00032 {
00033 
00034 #define kVersion 102
00035 #define LOG_SAMPLE_DURATION 3   // in millisecond
00036 
00037 //#define IO_CPU 1
00038 
00045 class JackCoreAudioDriver : public JackAudioDriver
00046 {
00047 
00048     private:
00049 #ifdef DEBUG
00050         //CALatencyLog* fLogFile;
00051 #endif
00052 
00053         AudioUnit fAUHAL;
00054 
00055         AudioBufferList* fJackInputData;
00056         AudioBufferList* fDriverOutputData;
00057 
00058         AudioDeviceID fDeviceID;
00059 
00060         AudioUnitRenderActionFlags fActionFags;
00061         AudioTimeStamp fCurrentTime;
00062 
00063         static  OSStatus Render(void *inRefCon,
00064                                AudioUnitRenderActionFlags *ioActionFlags,
00065                                const AudioTimeStamp *inTimeStamp,
00066                                UInt32 inBusNumber,
00067                                UInt32 inNumberFrames,
00068                                AudioBufferList *ioData);
00069 
00070         static OSStatus MeasureCallback(AudioDeviceID inDevice,
00071                                         const AudioTimeStamp* inNow,
00072                                         const AudioBufferList* inInputData,
00073                                         const AudioTimeStamp* inInputTime,
00074                                         AudioBufferList* outOutputData,
00075                                         const AudioTimeStamp* inOutputTime,
00076                                         void* inClientData);
00077 
00078         static OSStatus DeviceNotificationCallback(AudioDeviceID inDevice,
00079                 UInt32 inChannel,
00080                 Boolean isInput,
00081                 AudioDevicePropertyID inPropertyID,
00082                 void* inClientData);
00083 
00084         OSStatus GetDeviceIDFromUID(const char* UID, AudioDeviceID* id);
00085         OSStatus GetDefaultDevice(AudioDeviceID* id);
00086         OSStatus GetDefaultInputDevice(AudioDeviceID* id);
00087         OSStatus GetDefaultOutputDevice(AudioDeviceID* id);
00088         OSStatus GetDeviceNameFromID(AudioDeviceID id, char* name);
00089         OSStatus GetTotalChannels(AudioDeviceID device, long* channelCount, bool isInput);
00090 
00091     public:
00092 
00093         JackCoreAudioDriver(const char* name, JackEngine* engine, JackSynchro** table);
00094         virtual ~JackCoreAudioDriver();
00095 
00096         int Open(jack_nframes_t frames_per_cycle,
00097                  jack_nframes_t rate,
00098                  int capturing,
00099                  int playing,
00100                  int chan_in,
00101                  int chan_out,
00102                  bool monitor,
00103                  const char* capture_driver_name,
00104                  const char* playback_driver_name,
00105                  jack_nframes_t capture_latency,
00106                  jack_nframes_t playback_latency);
00107 
00108         int Close();
00109 
00110         int Attach();
00111 
00112         int Start();
00113         int Stop();
00114 
00115         int Read();
00116         int Write();
00117 
00118         int SetBufferSize(jack_nframes_t buffer_size);
00119 
00120         void PrintState();
00121 };
00122 
00123 } // end of namespace
00124 
00125 #endif

Generated on Wed Jan 10 11:42:44 2007 for Jackdmp by  doxygen 1.4.5