Created
April 12, 2017 01:08
-
-
Save onevcat/cc72e6946e27fe9bec0edfd6adc5f9c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var status: OSStatus | |
let readOrWrite = kAudioFileGlobalInfo_ReadableTypes | |
var propertySize: UInt32 = 0 | |
status = AudioFileGetGlobalInfoSize(readOrWrite, | |
0, | |
nil, | |
&propertySize) | |
print(status) | |
print(propertySize) | |
let typesAddress = UnsafeMutablePointer<AudioStreamBasicDescription>.allocate(capacity: Int(propertySize)) | |
status = AudioFileGetGlobalInfo(readOrWrite, | |
0, | |
nil, | |
&propertySize, | |
typesAddress) | |
let count = Int(propertySize) / MemoryLayout<AudioStreamBasicDescription>.size | |
for i in 0..<count { | |
var format4cc = typesAddress[i].mFormatID.bigEndian | |
withUnsafePointer(to: &format4cc) {ptr in | |
print(String(format: "%d: mFormatID: %4.4s, mFormatFlags: %d, mBitsPerChannel: %d", arguments: [i, ptr, typesAddress[i].mFormatFlags, typesAddress[i].mBitsPerChannel])) | |
} | |
} | |
typesAddress.deallocate(capacity: Int(propertySize)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment