Method captureOutput:(AVCaptureOutput *)captureOut

2019-05-27 00:05发布

I'm capturing audio from external bluetooth microphone. But I can't record anything.

This method is only called one time, at the beginning of the current AvCaptureSession.

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection

After that I never get called this method for process the audio.

For instantiate the capture session I do this:

self.captureSession.usesApplicationAudioSession = true;
self.captureSession.automaticallyConfiguresApplicationAudioSession = true;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];


/* Audio */
AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];


audioIn = [[AVCaptureDeviceInput alloc] initWithDevice:audioDevice error:nil];
if ( [_captureSession canAddInput:audioIn] ) {
    [_captureSession addInput:audioIn];
}
[audioIn release];

audioOut = [[AVCaptureAudioDataOutput alloc] init];
// Put audio on its own queue to ensure that our video processing doesn't cause us to drop audio
dispatch_queue_t audioCaptureQueue = dispatch_queue_create( "com.apple.sample.capturepipeline.audio", DISPATCH_QUEUE_SERIAL );
[audioOut setSampleBufferDelegate:self queue:audioCaptureQueue];

[audioCaptureQueue release];

if ( [self.captureSession canAddOutput:audioOut] ) {
    [self.captureSession addOutput:audioOut];
}
_audioConnection = [audioOut connectionWithMediaType:AVMediaTypeAudio];
[audioOut release];

If I use another bluetooth device is always working, but not with this one. I thought this device could be faulty, but actually is working in another apps to record audio.

Is really strange the problem. Anyone knows what could be happening?

Thanks!

0条回答
登录 后发表回答