Function

CMAudioFormatDescriptionCreate

Creates a format description for an audio media stream.

Declaration

OSStatus CMAudioFormatDescriptionCreate(CFAllocatorRef allocator, const AudioStreamBasicDescription *asbd, size_t layoutSize, const AudioChannelLayout *layout, size_t magicCookieSize, const void *magicCookie, CFDictionaryRef extensions, CMAudioFormatDescriptionRef  _Nullable *formatDescriptionOut);

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

CMAudioFormatDescriptionCreateSummary

Creates a summary audio format description from an array of audio format descriptions.

CMAudioFormatDescriptionEqual

Evaluates equality for the specified parts of two audio format descriptions.

CMAudioFormatDescriptionGetChannelLayout

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

CMAudioFormatDescriptionGetFormatList

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

CMAudioFormatDescriptionGetMagicCookie

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

CMAudioFormatDescriptionGetMostCompatibleFormat

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

CMAudioFormatDescriptionGetRichestDecodableFormat

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

CMAudioFormatDescriptionGetStreamBasicDescription

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

CMDoesBigEndianSoundDescriptionRequireLegacyCBRSampleTableLayout

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

CMSwapBigEndianSoundDescriptionToHost

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

CMSwapHostEndianSoundDescriptionToBig

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

CMAudioFormatDescriptionCreateFromBigEndianSoundDescriptionData

Creates a CMAudioFormatDescription from a big-endian SoundDescription data structure.

CMAudioFormatDescriptionCreateFromBigEndianSoundDescriptionBlockBuffer

Creates a CMAudioFormatDescription from a big-endian SoundDescription data structure in a CMBlockBuffer.

CMAudioFormatDescriptionCopyAsBigEndianSoundDescriptionBlockBuffer

Copies the contents of a CMAudioFormatDescription to a CMBlockBuffer in big-endian byte ordering.

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