<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AudioToolbox",
  "identifier" : "/documentation/AudioToolbox/AudioFileWritePacketsWithDependencies(_:_:_:_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Audio Toolbox"
    ],
    "preciseIdentifier" : "c:@F@AudioFileWritePacketsWithDependencies"
  },
  "title" : "AudioFileWritePacketsWithDependencies(_:_:_:_:_:_:_:_:)"
}
-->

# AudioFileWritePacketsWithDependencies(_:_:_:_:_:_:_:_:)

```
func AudioFileWritePacketsWithDependencies(_ inAudioFile: AudioFileID, _ inUseCache: Bool, _ inNumBytes: UInt32, _ inPacketDescriptions: UnsafePointer<AudioStreamPacketDescription>?, _ inPacketDependencies: UnsafePointer<AudioStreamPacketDependencyDescription>, _ inStartingPacket: Int64, _ ioNumPackets: UnsafeMutablePointer<UInt32>, _ inBuffer: UnsafeRawPointer) -> OSStatus
```

## Parameters

`inAudioFile`

The audio file to write to.

`inUseCache`

Set to `true` if you want to cache the data. Otherwise, set to `false`.

`inNumBytes`

The number of bytes of audio data being written.

`inPacketDescriptions`

A pointer to an array of packet descriptions for the audio data.
Not all formats require packet descriptions. If no packet descriptions
are required, for instance, if you are writing CBR data,  pass `NULL`.

`inPacketDependencies`

A pointer to an array of packet dependencies for the audio data.
This must not be `NULL`.  To write packets without dependencies,
use [`AudioFileWritePackets(_:_:_:_:_:_:_:)`](/documentation/AudioToolbox/AudioFileWritePackets(_:_:_:_:_:_:_:)) instead.

`inStartingPacket`

The packet index for the placement of the first provided packet.

`ioNumPackets`

On input, a pointer to the number of packets to write.
On output, a pointer to the number of packets actually written.

`inBuffer`

A pointer to user-allocated memory containing the new audio data
to write to the audio data file.

## Return Value

A result code. See Result Codes.

## Discussion

\abstract Write packets of audio data with corresponding packet dependencies to an audio data file.
\discussion For all uncompressed formats, `packets == frames`.

---

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)