Funny, does not work for me. The underlying rawValue I get is an actual address, not 0x0. Naturally, AudioUnitGetProperty returns -50. I am on iOS. Perhaps the API yields different results for different OS?
Am 19.10.2016 um 17:53 schrieb Matt Grippaldi < email@hidden>:
This worked for me calling MusicTrackGetPropertyThis is a hack as far as I am concerned
let nullPtr:UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 0, alignedTo: 0)
status = MusicTrackGetProperty(tempoTrack!, kSequenceTrackProperty_TimeResolution, nullPtr, &propertyLength);
The values returned for propertyLength was correct and the subsequent call to get the time resolution was also had the correct result.
Matt GrippaldiOn Oct 19, 2016, at 10:09 AM, Vieira Damiani, Luis F < email@hidden> wrote:
How about something like this:
let outputData: UnsafeMutableRawPointer
if let bOData = bO.mData { // Might be a nil?
outputData = bOData
} else {
outputData = inputData
bO.mData = inputData
assert(false)
}
This came from vgorloff's Swift 3 implementation of a host and audiounit -- you can find it on Github.
Sent from my iPhone
On Oct 19, 2016, at 9:49 AM, Benjamin Federer < email@hidden> wrote:
Thanks, Matt
Unfortunately this does not work. Since the line creates an explicitly unwrapped optional containing nil, AudioUnitGetProperty fails at runtime, just as passing in nil directly would (if the compiler would allow it):
fatal error: unexpectedly found nil while unwrapping an Optional value
For what it’s worth I am currently querying the maximum property size using AudioUnitGetPropertyInfo, then getting the property data using AudioUnitGetProperty and finally slicing off the portion of relevant data reported by the ioDataSize out
value.
Benjamin
Am 19.10.2016 um 15:21 schrieb Matt Grippaldi < email@hidden>:
Try this…
let nullPtr:UnsafeMutableRawPointer!
= nil
On Oct 19, 2016, at 7:13 AM, Benjamin Federer < email@hidden> wrote:
Hi there, especially the Core Audio team,
The documentation for AudioUnitGetProperty() says:
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.
I cannot, for the life of me, get Swift 3 to create a NULL pointer. With Swift 2 it seems this was possible. With Swift 3 I am supposed to pass in nil instead. But since outData is a non-optional I am not allowed to do that.
Interestingly, AudioUnitGetPropertyInfo() also works with passing NULL for its inOut parameters, which are optionals:
public
func AudioUnitGetPropertyInfo(_
inUnit: AudioUnit,
_ inID:
AudioUnitPropertyID,
_ inScope:
AudioUnitScope,
_ inElement:
AudioUnitElement,
_ outDataSize:
UnsafeMutablePointer<UInt32>?,
_ outWritable:
UnsafeMutablePointer<DarwinBoolean>?)
-> OSStatus
Is outData being a non-optional intentional and, if so, how should I pass in NULL?
Thanks,
Benjamin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list ( email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
|