如何在Swift中将UnsafeMutablePointer <audiobufferlist>转换为AudioBuffer?

时间:2016-05-06 17:35:33

标签: ios swift swift2 core-audio audiounit

我设置了AURenderCallbackStruct音频单元。在回调中,我将音频数据设为ioData: UnsafeMutablePointer<AudioBufferList>。检查下面的代码。

func renderCallback(inRefCon: UnsafeMutablePointer<Void>, ioActionFlag: UnsafeMutablePointer<AudioUnitRenderActionFlags>, inTimeStamp: UnsafePointer<AudioTimeStamp>, inBufferNumber: UInt32, inNumberFrames: UInt32, ioData: UnsafeMutablePointer<AudioBufferList>) -> OSStatus {

    // How can i get AudioBuffer from iodate here ?

    return noErr
}

我如何从AudioBuffer获取ioDate?请建议......

N.B。我正在使用swift 2.2

1 个答案:

答案 0 :(得分:3)

只需使用任何memory的{​​{1}}属性即可访问其原始内存。所以你的代码看起来应该是这样的。

UnsafeMutablePointer<>

N.B。 Swift是一种快速发展的语言。所以这段代码将来可能会改变。