13
我正在開發一款應用程序,在該應用程序中,我需要通過輸出音頻插孔同時錄製和保存視頻來傳遞音頻。將CMSampleBufferRef數據傳遞到音頻輸出插孔
我已經看着aurio觸摸蘋果示例代碼並實現了音頻直通。
我也通過AVCaptureSession
實施了視頻錄製。 以上兩個功能都單獨完成,並且完美地工作。
但是,當我合併功能音頻通過不工作,因爲AVCapturesession
的音頻會話。
我也嘗試通過音頻數據,我從AVCaptureSession
委託方法獲得。以下是我的代碼:
OSStatus err = noErr;
AudioBufferList audioBufferList;
CMBlockBufferRef blockBuffer;
CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
CMItemCount numberOfFrames = CMSampleBufferGetNumSamples(sampleBuffer); // corresponds to the number of CoreAudio audio frames
currentSampleTime += (double)numberOfFrames;
AudioTimeStamp timeStamp;
memset(&timeStamp, 0, sizeof(AudioTimeStamp));
timeStamp.mSampleTime = currentSampleTime;
timeStamp.mFlags |= kAudioTimeStampSampleTimeValid;
AudioUnitRenderActionFlags flags = 0;
aurioTouchAppDelegate *THIS = (aurioTouchAppDelegate *)[[UIApplication sharedApplication]delegate];
err = AudioUnitRender(self.rioUnit, &flags, &timeStamp, 1, numberOfFrames, &audioBufferList);
if (err) { printf("PerformThru: error %d\n", (int)err); }
但它給錯誤。請告知可以儘快做些什麼。我查閱了很多文檔和許多代碼,但找不到任何解決方案。請幫忙..