问题
The AVAudioRecorder Class Reference found here:
https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVAudioRecorder_ClassReference/Reference/Reference.html#//apple_ref/doc/uid/TP40008238
says that AVAudioSession can be used to configure the audio session
To configure an appropriate audio session for recording, refer to AVAudioSession Class Reference and AVAudioSessionDelegate Protocol Reference.
But the AVFoundation Framework lacks the AVAudioSession on OS X.
So we get the error, use of undeclared identifier AVAudioSession
.
So I looked into OS X AVFoundation Framework and found out that AVAudioSession.h is missing!
Any thoughts on this?
回答1:
Use Audio Hardware Services (https://developer.apple.com/library/mac/documentation/AudioToolbox/Reference/AudioHardwareServicesReference/) instead of AVAudioSession. Here is the possible solution: AVAudioSession alternative on OSX to get audio driver sample rate
I made some small modifications like the lines:
AudioDeviceID deviceID;
OSStatus err = AudioHardwareServiceGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &size, &deviceID);
来源:https://stackoverflow.com/questions/11867657/using-avaudiorecorder-on-mac