Function

CMAudioFormatDescriptionCreate(allocator:asbd:layoutSize:layout:magicCookieSize:magicCookie:extensions:formatDescriptionOut:)

Creates a format description for an audio media stream.

Declaration

func CMAudioFormatDescriptionCreate(allocator: CFAllocator?, asbd: UnsafePointer<AudioStreamBasicDescription>, layoutSize: Int, layout: UnsafePointer<AudioChannelLayout>?, magicCookieSize: Int, magicCookie: UnsafeRawPointer?, extensions: CFDictionary?, formatDescriptionOut: UnsafeMutablePointer<CMAudioFormatDescription?>) -> OSStatus

Parameters

allocator

CFAllocator to be used. Pass kCFAllocatorDefault or NULL to use the default allocator.

asbd

Audio format description (see CoreAudioTypes.h). This information is required.

layoutSize

Size, in bytes, of audio channel layout. 0 if layout is NULL.

layout

Audio channel layout (see CoreAudioTypes.h). Can be NULL.

magicCookieSize

Size, in bytes, of magic cookie. 0 if magicCookie is NULL.

magicCookie

Magic cookie. This information is required for some formats, and must be NULL for all others.

extensions

Dictionary of extension key/value pairs. Keys are always CFStrings. Values are always property list objects (ie. CFData, CFString, CFArray, CFDictionary, CFDate, CFBoolean, or CFNumber). Can be NULL.

outDesc

On output, returns the newly created audio CMFormatDescription.

Return Value

A result code. See “Result Codes”

Discussion

The ASBD is required, the channel layout is optional, and the magic cookie is required for some compression formats (and must be NULL for all others). The caller owns the returned CMFormatDescription, and must release it when done with it. The ASBD, magic cookie, channel layout, and extensions are all copied (the extensions are deep-copied). The caller can deallocate them or re-use them after making this call.

See Also

Audio-Specific Functions

func CMAudioFormatDescriptionGetChannelLayout(CMAudioFormatDescription, sizeOut: UnsafeMutablePointer<Int>?) -> UnsafePointer<AudioChannelLayout>?

Returns a read-only pointer to (and size of) the AudioChannelLayout inside an audio CMFormatDescription.

func CMAudioFormatDescriptionGetFormatList(CMAudioFormatDescription, sizeOut: UnsafeMutablePointer<Int>?) -> UnsafePointer<AudioFormatListItem>?

Returns a read-only pointer to (and size of) the array of AudioFormatListItem structs inside an audio CMFormatDescription.

func CMAudioFormatDescriptionGetMagicCookie(CMAudioFormatDescription, sizeOut: UnsafeMutablePointer<Int>?) -> UnsafeRawPointer?

Returns a read-only pointer to (and size of) the magic cookie inside an audio CMFormatDescription.

func CMAudioFormatDescriptionGetMostCompatibleFormat(CMAudioFormatDescription) -> UnsafePointer<AudioFormatListItem>?

Returns a read-only pointer to the appropriate AudioFormatListItem inside an audio CMFormatDescription.

func CMAudioFormatDescriptionGetRichestDecodableFormat(CMAudioFormatDescription) -> UnsafePointer<AudioFormatListItem>?

Returns a read-only pointer to the appropriate AudioFormatListItem inside an audio CMFormatDescription.

func CMAudioFormatDescriptionGetStreamBasicDescription(CMAudioFormatDescription) -> UnsafePointer<AudioStreamBasicDescription>?

Returns a read-only pointer to the AudioStreamBasicDescription inside an audio CMFormatDescription.

func CMDoesBigEndianSoundDescriptionRequireLegacyCBRSampleTableLayout(CMBlockBuffer, flavor: CMSoundDescriptionFlavor?) -> Bool

Examine a big-endian SoundDescription data structure in a CMBlockBuffer, and report whether the sample tables will need to use the legacy CBR layout.

func CMSwapBigEndianSoundDescriptionToHost(UnsafeMutablePointer<UInt8>, Int) -> OSStatus

Converts a SoundDescription data structure from big-endian to host-endian in place.

func CMSwapHostEndianSoundDescriptionToBig(UnsafeMutablePointer<UInt8>, Int) -> OSStatus

Converts a SoundDescription data structure from host-endian to big-endian in place.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software