2

我正在从外部蓝牙麦克风捕获音频。但是我什么都录不了。

此方法仅在当前 AvCaptureSession 开始时调用一次。

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

之后,我再也没有被称为处理音频的这种方法。

为了实例化捕获会话,我这样做:

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];

如果我使用另一个蓝牙设备总是可以工作,但不是这个。我认为这个设备可能有故障,但实际上正在另一个应用程序中工作以录制音频。

真是奇怪的问题。有谁知道会发生什么?

谢谢!

4

0 回答 0