我正在开发一个简单的 Cocoa 应用程序,该应用程序从 AVAudioRecorder 中检索仪表。这是我的代码:
@interface AppDelegate () <AVAudioRecorderDelegate>
@property (weak) IBOutlet NSWindow *window;
@property (strong) AVAudioRecorder *recorder;
@property (strong) NSURL *dump;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSDictionary *settings = @{AVSampleRateKey: @(44100.0),
AVNumberOfChannelsKey: @2,
AVFormatIDKey: @(kAudioFormatAppleLossless),
AVEncoderAudioQualityKey: @(AVAudioQualityHigh)
};
NSError *error = nil;
self.dump = [[NSURL alloc] initFileURLWithPath: [NSTemporaryDirectory() stringByAppendingString: @"dump"]];
self.recorder = [[AVAudioRecorder alloc] initWithURL: self.dump
settings: settings
error: &error];
NSLog(@"Recorder, got error? %@", error);
self.recorder.delegate = self;
[self.recorder prepareToRecord];
self.recorder.meteringEnabled = YES;
[self.recorder record];
}
@end
我还有一个计时器,每秒检索一次仪表。它适用于我的笔记本电脑,但在我的 iMac 上,由于某种原因,当我调用记录时,我在“com.apple.audio.IOThread.client (8)”上有一个 BAD_ACCESS。
任何想法 ?
谢谢!