This worked for me calling MusicTrackGetProperty
This 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 Grippaldi
> On Oct 19, 2016, at 10:09 AM, Vieira Damiani, Luis F <[email protected]> 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 protected]
> <mailto:[email protected]>> 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 protected]
>>> <mailto:[email protected]>>:
>>>
>>> Try this…
>>>
>>> let nullPtr:UnsafeMutableRawPointer! = nil
>>>
>>> Matt Grippaldi
>>> [email protected] <mailto:[email protected]>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> On Oct 19, 2016, at 7:13 AM, Benjamin Federer <[email protected]
>>>> <mailto:[email protected]>> 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 protected]
>>>> <mailto:[email protected]>)
>>>> Help/Unsubscribe/Update your Subscription:
>>>> https://lists.apple.com/mailman/options/coreaudio-api/mattg%40kinematicsystems.com
>>>>
>>>> <https://lists.apple.com/mailman/options/coreaudio-api/mattg%40kinematicsystems.com>
>>>>
>>>> This email sent to [email protected]
>>>> <mailto:[email protected]>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Coreaudio-api mailing list ([email protected]
>> <mailto:[email protected]>)
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/coreaudio-api/damiani%40ufl.edu
>> <https://lists.apple.com/mailman/options/coreaudio-api/damiani%40ufl.edu>
>>
>> This email sent to [email protected]
>> <mailto:[email protected]>_______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/coreaudio-api/mattg%40kinematicsystems.com
>
> This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com
This email sent to [email protected]