OK, so I am new to IPhone development, but I guess this is an error I won't be making any more!
In iOS 5.1, this code should have printed a lot of "Yeah, we've got something"'s... But in stead, all I got was Mar 15 00:54:47 unknown mediaserverd[43] <Error>: 00:54:47.702 <0x2745000> AURemoteIO::ChangeHardwareFormats: error -10875
- (void)viewDidLoad
{
[super viewDidLoad];
AVCaptureDevice *audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioCaptureDevice error:nil];
[captureSession addInput:audioInput];
AVCaptureAudioDataOutput *audioOutput = [[AVCaptureAudioDataOutput alloc] init];
[audioOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
[captureSession addOutput:audioOutput];
[captureSession startRunning];
}
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
NSLog(@"Yeah, we got something!");
}
Turns out somehow garbage collection (or whatever you want to call it: auto ref count, etc) messed things up... Specifying the variables as instance vars in stead of local vars, fixed things!