AVAudioRecorder and iOS 5.1
I have an application that records audio using AVAudioRecorder. It works fine on devices with iOS versions prior to iOS 5.1, but with the latest version, it does not increase the file size of the audio recording, which remains at a constant 4k speed.
// init audio recorder here so recording could be started immediately
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatAppleIMA4],
AVFormatIDKey,
[NSNumber numberWithInt: 1],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
// Get temp path name
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [paths objectAtIndex:0];
BOOL isDir = NO;
NSError *error = nil;
if (![[NSFileManager defaultManager] fileExistsAtPath:cachePath isDirectory:&isDir] && isDir == NO) {
[[NSFileManager defaultManager] createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:&error];
}
self.audioFilePath = [cachePath stringByAppendingPathComponent:@"audio.ima4"];
NSURL *audioFileURL = [NSURL fileURLWithPath:self.audioFilePath];
AVAudioRecorder *anAudioRecorder = [[AVAudioRecorder alloc] initWithURL:audioFileURL
settings:recordSettings
error:&error];
self.audioRecorder = anAudioRecorder;
[anAudioRecorder release];
[self.audioRecorder prepareToRecord];
(wait a while, user clicks record) [self.audioRecorder record]; (wait a while, 5-10 seconds, user stops stop) [self.audioRecorder stop];
I posted debug statements that check the temp file size and is 4096 bytes throughout the entire write, and only 4130 bytes after the stop call.
I don't see any way around this. Is this a bug in iOS 5.1?
+3
source to share
No one has answered this question yet
Check out similar questions: