Search code examples
swiftaudioavfoundationavplayer

How to pass tapStorageOut to clientInfo in MTAudioProcessingTapInitCallback


Im trying to convert to Swift this tutorial that explains how to use MTAudioProcessingTap. In the MTAudioProcessingTapInitCallback it is passing the clientInfo which is a UnsafeMutablePointer<UnsafeMutableRawPointer?> to the tapStorageOut which is a UnsafeMutableRawPointer?

like this in Objc:

void init(MTAudioProcessingTapRef tap, void *clientInfo, void **tapStorageOut)
{
    NSLog(@"Initialising the Audio Tap Processor");
    *tapStorageOut = clientInfo;
}

Now the question is.. how I do that in Swift ?

let tapInit: MTAudioProcessingTapInitCallback = {
        (tap, clientInfo, tapStorageOut) in

        print("init \(tap, clientInfo, tapStorageOut)\n")

    }

Solution

  • tapStorageOut.pointee = clientInfo
    

    p.s not a swift thing, but I’ve never understood why taps allow tapStorage and clientInfo to differ.