I am following Apple's documentation for recording audio on iPhone using class AVAudioSession. I can set a few properties with no errors ( setActive, setCategory, setPreferredHardwareSampleRate), but I can not make the Apple sample code to work setPreferredIOBufferDuration.
Here is my code:
- (void) initX {
NSError *setPreferenceError = nil;
NSTimeInterval preferredBufferDuration = 0.005;
[[AVAudioSession sharedInstance]
setPreferredIOBufferDuration: preferredBufferDuration
error: &setPreferenceError];
if (setPreferenceError != nil) {
NSLog( @"%@", setPreferenceError );
}
}
He produces the following conclusion:
Domain Error = NSOSStatusErrorDomain Code = 561211770 "Operation could not be completed (OSStatus error 561211770.)"
I call this method from the main delegate of the application, as part of the method applicationDidFinishLaunching. All I do is initialize things at this point. I imported AVFoundation / AVFoundation.h after adding AVFoundation.framework to the project.