2

我正在捕获音频AVCaptureSession,现在我要播放它。

我真的不喜欢较低级别的音频处理,所以这ObjectAL似乎是一个公平的选择,所以我尝试获取缓冲区指针、一些格式信息,然后创建一个 ObjectAL 缓冲区。

 -(void)captureOutput:(AVCaptureOutput*) captureOutput
didOutputSampleBuffer:(CMSampleBufferRef) sampleBuffer
       fromConnection:(AVCaptureConnection*) connection
{
    if ([captureOutput isKindOfClass:[AVCaptureAudioDataOutput class]])
    {

        // Get samples.
        CMBlockBufferRef audioBuffer = CMSampleBufferGetDataBuffer(sampleBuffer);
        size_t lengthAtOffset;
        size_t totalLength;
        char *samples;
        CMBlockBufferGetDataPointer(audioBuffer, 0, &lengthAtOffset, &totalLength, &samples);

        // Get format.
        CMAudioFormatDescriptionRef format = CMSampleBufferGetFormatDescription(sampleBuffer);
        const AudioStreamBasicDescription *description = CMAudioFormatDescriptionGetStreamBasicDescription(format);

        ALBuffer *openALbuffer = [ALBuffer bufferWithName:@"buffer just captured before"
                                                     data:sampleBuffer
                                                     size:totalLength
                                                   format:description->mFormatID
                                                frequency:description->mSampleRate];
    }
}

它说Invalid Value

OAL Error: +[ALWrapper bufferDataStatic:format:data:size:frequency:]: Invalid Value (error code 0x0000a003)

ObjectAL 实际上挂钩了一些我没有涉及的 OpenAL 内容,您可能会更好地理解它:ALBuffer.mALWrapper.m

在创建此类 ObjectAL (OpenAL) 缓冲区之前,我必须使用任何格式/缓冲区对话吗?

4

0 回答 0