无法使用AVAudioRecorder,com.apple.audio.IOThread.client上的访问权限不佳

时间:2014-11-05 18:37:23

标签: cocoa avfoundation exc-bad-access avaudiorecorder metering

我正在研究一个简单的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上,出于某种原因我在&#34; com.apple.audio.IOThread.client(8)&#34;上有一个BAD_ACCESS。当我打电话给记录时。

有什么想法吗?

谢谢!

0 个答案:

没有答案