How do I call CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer?

后端 未结 6 1037
北荒
北荒 2021-01-13 04:10

I\'m trying to figure out how to call this AVFoundation function in Swift. I\'ve spent a ton of time fiddling with declarations and syntax, and got this far.

6条回答
  •  无人共我
    2021-01-13 04:48

    I do this (swift 4.2):

    let n = CMSampleBufferGetNumSamples(audioBuffer)
    let format = CMSampleBufferGetFormatDescription(audioBuffer)!
    let asbd = CMAudioFormatDescriptionGetStreamBasicDescription(format)!.pointee
    
    let nChannels = Int(asbd.mChannelsPerFrame) // probably 2
    let bufferlistSize = AudioBufferList.sizeInBytes(maximumBuffers: nChannels)
    let abl = AudioBufferList.allocate(maximumBuffers: nChannels)
    for i in 0..

提交回复
热议问题