Core Audio SDK is broken since Swift 3

Originator:benjamin
Number:rdar://28956261 Date Originated:26-Oct-2016
Status:Open Resolved:
Product:iOS Product Version:10.1
Classification: Reproducible:Yes
 
Summary:
Swift 3 does not allow NULL pointers (https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md). User programmers are expected to pass in nil for function arguments that are optional. The AudioUnitGetProperty() function expects a NULL pointer, but lacks the optional argument.
 
public func AudioUnitGetProperty(_ inUnit: AudioUnit, _ inID: AudioUnitPropertyID, _ inScope: AudioUnitScope, _ inElement: AudioUnitElement, _ outData: UnsafeMutableRawPointer, _ ioDataSize: UnsafeMutablePointer<UInt32>) -> OSStatus

"outData: … Set this parameter to NULL when calling this function if you only want to determine how much memory to allocate for a variable size property."

The following also came up on the Core Audio mailing list:

public func MusicTrackGetProperty(_ inTrack: MusicTrack, _ inPropertyID: UInt32, _ outData: UnsafeMutableRawPointer, _ ioLength: UnsafeMutablePointer<UInt32>) -> OSStatus

"If outData is NULL, then the size of the data will be passed back in ioLength"

AudioUnitConnection

"We used to be able to pass nill to sourceAudioUnit to disconnect. AudioUnitConnection.sourceAudioUnit needs to become optional."

Steps to Reproduce:
var outputChannelSize : UInt32 = 0
var error : OSStatus = AudioUnitGetProperty(outputUnit, kAudioOutputUnitProperty_ChannelMap, kAudioUnitScope_Output, 0, nil, &outputChannelSize)

Expected Results:
outputChannelSize should be filled in with the property size.

Actual Results:
The above code will not compile with Xcode 8.

Version:
iOS 10.1, macOS 10.12.1, Xcode 8

Notes:
The respective thread on the Core Audio mailing list starts here: http://lists.apple.com/archives/coreaudio-api/2016/Oct/msg00008.html

Configuration:
any device

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!