0
在我的可可應用程序中,我嘗試從內部麥克風錄製聲音。我正在使用AVAudioRecorder類來達到此目的。在下面的代碼中,我設置AVAudioRecorder實例。AVAudioRecorder不記錄在OS X小牛
- (void)setupAudioRecorder {
NSMutableDictionary *recordSettings = [NSMutableDictionary dictionary];
recordSettings[AVFormatIDKey] = @(kAudioFormatLinearPCM);
recordSettings[AVSampleRateKey] = @(16000.0);
recordSettings[AVNumberOfChannelsKey] = @(1);
recordSettings[AVLinearPCMBitDepthKey] = @(16);
recordSettings[AVLinearPCMIsBigEndianKey] = @(NO);
recordSettings[AVLinearPCMIsFloatKey] = @(NO);
recordSettings[AVEncoderBitRateStrategyKey] = AVAudioBitRateStrategy_Variable;
recordSettings[AVEncoderAudioQualityForVBRKey] = @(AVAudioQualityMedium);
recordSettings[AVSampleRateConverterAlgorithmKey] = AVSampleRateConverterAlgorithm_Mastering;
recordSettings[AVSampleRateConverterAudioQualityKey] = @(AVAudioQualityMedium);
NSString *file = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)
objectAtIndex:0]
stringByAppendingPathComponent:@".recorder_voice.caf"];
NSFileManager *fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:file])
[fm removeItemAtPath:file error:nil];
NSURL *url = [NSURL fileURLWithPath:file];
NSError *err = nil;
self.recorder.delegate = nil;
self.recorder = [[AVAudioRecorder alloc] initWithURL:url
settings:recordSettings
error:&err];
if(!self.recorder){
// show error
}
[self.recorder setDelegate:self];
[self.recorder prepareToRecord];
self.recorder.meteringEnabled = YES;
}
在優勝美地一切正常,但在小牛我沉默。系統日誌在執行時顯示錯誤[self.recorder prepareToRecord];:
AQMEIO.cpp:377 _FindIOUnit:error -66680。
這是什麼意思,我該如何解決?