2
응용 프로그램 사운드를 캡처하여 AVAssetWriter에 입력으로 전달하려고합니다.
AudioBufferList를 가져 오기 위해 오디오 장치에 대한 콜백을 설정 중입니다.
이 문제는 AudioBufferList를 CMSampleBufferRef로 변환하는 것으로 시작됩니다. 필수 매개 변수는 카롤CMSampleBufferSetDataBufferFromAudioBufferList 반환 오류 12731
감사
누락되어 있음을 나타냅니다
그것은 항상 오류 -12731 반환은
-(OSStatus) recordingCallbackWithRef:(void*)inRefCon
flags:(AudioUnitRenderActionFlags*)flags
timeStamp:(const AudioTimeStamp*)timeStamp
busNumber:(UInt32)busNumber
framesNumber:(UInt32)numberOfFrames
data:(AudioBufferList*)data
{
AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mData = NULL;
OSStatus status;
status = AudioUnitRender(audioUnit,
flags,
timeStamp,
busNumber,
numberOfFrames,
&bufferList);
[self checkOSStatus:status];
AudioStreamBasicDescription audioFormat;
// Describe format
audioFormat.mSampleRate = 44100.00;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBitsPerChannel = 16;
audioFormat.mBytesPerPacket = 2;
audioFormat.mBytesPerFrame = 2;
CMSampleBufferRef buff = NULL;
CMFormatDescriptionRef format = NULL;
CMSampleTimingInfo timing = { CMTimeMake(1, 44100), kCMTimeZero, kCMTimeInvalid };
status = CMAudioFormatDescriptionCreate(kCFAllocatorDefault, &audioFormat, 0, NULL, 0, NULL, NULL, &format);
[self checkOSStatus:status];
status = CMSampleBufferCreate(kCFAllocatorDefault,NULL,false,NULL,NULL,format,1, 1, &timing, 0, NULL, &buff);
[self checkOSStatus:status];
status = CMSampleBufferSetDataBufferFromAudioBufferList(buff,
kCFAllocatorDefault,
kCFAllocatorDefault,
0,
&bufferList);
[self checkOSStatus:status]; //Status here is 12731
//Do something with the buffer
return noErr;
}
편집 : 나는 bufferList.mBuffers을 확인
[0] .mData 그것은 null가 아닌 그래서 아마도 그것은 문제가 아닙니다.
당신이 당신의'audioUnit'을 정의하는 방법? –