我在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.m
,ALWrapper.m