Hello,
I have been following Apple's documentation to record audio on the iPhone using the AVAudioSession class. I can set several properties without error ( setActive, setCategory, setPreferredHardwareSampleRate ) but I cannot get Apple's sample code to work for setPreferredIOBufferDuration.
Here's my code:
- (void) initX {
NSError *setPreferenceError = nil; NSTimeInterval preferredBufferDuration = 0.005;
[[AVAudioSession sharedInstance] setPreferredIOBufferDuration: preferredBufferDuration error: &setPreferenceError];
if (setPreferenceError != nil) { NSLog( @"%@", setPreferenceError ); } }
It produces the following output:
Error Domain=NSOSStatusErrorDomain Code=561211770 "Operation could not be completed. (OSStatus error 561211770.)"
I am calling this method from the main Application Delegate, as part of the applicationDidFinishLaunching method. All I am doing is initializing things at this stage. I have imported AVFoundation/AVFoundation.h after adding AVFoundation.framework to the project.
Any suggestions would be appreciated.