<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMAudioFormatDescriptionGetMagicCookie(_:sizeOut:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@F@CMAudioFormatDescriptionGetMagicCookie"
  },
  "title" : "CMAudioFormatDescriptionGetMagicCookie(_:sizeOut:)"
}
-->

# CMAudioFormatDescriptionGetMagicCookie(_:sizeOut:)

Returns a read-only pointer to, and size of, the magic cookie in an audio format description.

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

## Parameters

`desc`

`CMFormatDescription` being interrogated.

`sizeOut`

Pointer to variable that will be written with the size of the cookie. Can be `NULL`.

## Return Value

A read-only pointer to the magic cookie inside the audio format description.

## Discussion

The magic cookie is a completely opaque piece of data, written and read only by the codec itself. A magic cookie is only present for codecs that require it;  this API will return `NULL` if one does not exist. This API is specific to audio format descriptions, and will return `NULL` if called with a non-audio format description.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)