2012-05-22 63 views
2

我有這個代碼,即時嘗試用來捕獲音頻數據。但是編譯器抱怨CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer_CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer的未定義符號

-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { 
     AudioBufferList audioBufferList; 
     NSMutableData *data= [[NSMutableData alloc] init]; 
     CMBlockBufferRef blockBuffer; 
     CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer); 

     for (int y = 0; y < audioBufferList.mNumberBuffers; y++) { 
      AudioBuffer audioBuffer = audioBufferList.mBuffers[y]; 
      Float32 *frame = (Float32*)audioBuffer.mData; 

      [data appendBytes:frame length:audioBuffer.mDataByteSize]; 
     } 
    CFRelease(blockBuffer); 
    blockBuffer=NULL; 
    [data release]; 
} 

錯誤:

Undefined symbols for architecture armv7:
"_CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer", referenced from: -[MicCommunicator captureOutput:didOutputSampleBuffer:fromConnection:] in MicCommunicator.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

+0

有什麼原因讓你將幀添加到單個數據中?我問的原因是我使用相同的函數CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer來抓取數據並通過網絡發送,以便通過AudioQueue讀取..但由於某種原因它到達了所有加標籤的東西..我不認爲它是ABSD格式化問題,因爲我使用發送方和接收方的標準lPCM .. – abbood

+0

@ www.fossfactory.org是的。我用於發送的httpclient以NSData/NSMutableData作爲參數。所以對我來說使用它作爲容器是最簡單的。任何時候我亂碼都是因爲它使用了錯誤的格式(不是ulaw)。但我的設置是不同的。 –

+0

我知道這是一個警察出來,但我花了一個多星期的格式化(和其他所有)擺弄,但沒有結果..檢查出這個問題的代碼(你看到格式化有什麼問題嗎? )我只是使用PCM格式進出: http://stackoverflow.com/questions/12264799/why-is-audio-coming-up-garbled-when-using-avassetreader-with-audio-queue – abbood

回答

5

鏈接器沒有找到一個符號表示包含符號庫/框架未列出作爲構建目標的依賴。在Xcode中,選擇您的目標,進入'Build Phases',打開'Link Binary with Libraries'並添加CoreMedia。

+0

我向你發誓,我看到這個後尋找coremedia(http://disanji.net/iOS_Doc/#documentation/CoreMedia/Reference/CMSampleBuffer/Reference/reference.html),但它並沒有在那裏。但是當你說這個並找到它時,我再次看了看。所以idk wtf會發生,但是謝謝 –

+0

不錯。爲你快速回答;容易勾選我!對? – GoZoner

+0

雅它讓我等4分鐘:) –