I'm working on a simple Cocoa application that retrieve the meters from an AVAudioRecorder. Here is my code:
@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
I also have a timer that retrieves the meters every second. It works on my laptop but on my iMac, for some reason I have a BAD_ACCESS on "com.apple.audio.IOThread.client (8)" when I call record.
Any idea ?
Thanks!