I've been banging my head on the wall for hours trying to create a MTAudioProcessingTapCallbacks
from the MediaToolbox
library, using Swift 2. I found this great article with an implementation in Objective-C, so I thought I would try to re-write it in Swift, so that I can understand it better, however that is proving a bit beyond me at the moment.
The main issue is that I can't find a way to cast the return value of MTAudioProcessingTapGetStorage(tap)
(which is an UnsafeMutablePointer<Void>
) to an RMStreamer
, which appears to be a feature of the original implementation:
RMStreamer *streamer = (__bridge RMStreamer *) MTAudioProcessingTapGetStorage(tap);
If I attempt this in the most obvious way:
var streamer = MTAudioProcessingTapGetStorage(tap) as! RMStreamer
I get a warning saying:
Cast from UnsafeMutablePointer (aka 'UnsafeMutablePointer<()> to unrelated type RMStreamer always fails)"
So, I found out that the __bridge
is somehow equivalent to takeUnretainedValue()
but that method does not seem to be available anywhere in this context. I suspect I'm being rather ignorant, but does anyone know if it is possible to implement this kind of thing in Swift 2, or am I better off just learning Objective-C and using that for MediaToolbox
stuff in future?