---
title: "CMSampleBufferGetAudioStreamPacketDescriptions(_:allocatedSize:packetDescriptionsOut:packetDescriptionsSizeNeededOut:)"
framework: coremedia
role: symbol
role_heading: Function
path: "coremedia/cmsamplebuffergetaudiostreampacketdescriptions(_:allocatedsize:packetdescriptionsout:packetdescriptionssizeneededout:)"
---

# CMSampleBufferGetAudioStreamPacketDescriptions(_:allocatedSize:packetDescriptionsOut:packetDescriptionsSizeNeededOut:)

Creates an array of audio stream packet descriptions.

## Declaration

```swift
func CMSampleBufferGetAudioStreamPacketDescriptions(_ sbuf: CMSampleBuffer, allocatedSize packetDescriptionsSize: Int, packetDescriptionsOut: UnsafeMutablePointer<AudioStreamPacketDescription>?, packetDescriptionsSizeNeededOut: UnsafeMutablePointer<Int>?) -> OSStatus
```

## Parameters

- `sbuf`: CMSampleBuffer being accessed.
- `packetDescriptionsSize`: Size of packetDescriptionsOut as allocated by the caller.
- `packetDescriptionsOut`: Allocated by the caller, receives the packet descriptions for the samples in the CMSampleBuffer. If non-NULL and packetDescriptionsSize is too small, kFigSampleBufferError_ArrayTooSmall is returned.
- `packetDescriptionsSizeNeededOut`: Used to query for the correct size required for packetDescriptionsOut. May be NULL.

## Return Value

Return Value A result code. See Sample Buffer Error Codes.

## Discussion

Discussion Creates an array of AudioStreamPacketDescriptions for the variable bytes per packet or variable frames per packet audio data in the provided CMSampleBuffer. Constant bit rate, constant frames-per-packet audio yields a return value of noErr and no packet descriptions. This API is specific to audio format sample buffers, and will return kCMSampleBufferError_InvalidMediaTypeForOperation if called with a non-audio sample buffer.

## See Also

### Modifying Sample Buffers

- [CMSampleBufferGetDataBuffer(_:)](coremedia/cmsamplebuffergetdatabuffer(_:).md)
- [CMSampleBufferSetDataBuffer(_:newValue:)](coremedia/cmsamplebuffersetdatabuffer(_:newvalue:).md)
- [CMSampleBufferGetImageBuffer(_:)](coremedia/cmsamplebuffergetimagebuffer(_:).md)
- [CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(_:bufferListSizeNeededOut:bufferListOut:bufferListSize:blockBufferAllocator:blockBufferMemoryAllocator:flags:blockBufferOut:)](coremedia/cmsamplebuffergetaudiobufferlistwithretainedblockbuffer(_:bufferlistsizeneededout:bufferlistout:bufferlistsize:blockbufferallocator:blockbuffermemoryallocator:flags:blockbufferout:).md)
- [CMSampleBufferSetDataBufferFromAudioBufferList(_:blockBufferAllocator:blockBufferMemoryAllocator:flags:bufferList:)](coremedia/cmsamplebuffersetdatabufferfromaudiobufferlist(_:blockbufferallocator:blockbuffermemoryallocator:flags:bufferlist:).md)
- [CMSampleBufferCopyPCMDataIntoAudioBufferList(_:at:frameCount:into:)](coremedia/cmsamplebuffercopypcmdataintoaudiobufferlist(_:at:framecount:into:).md)
- [CMSampleBufferGetAudioStreamPacketDescriptionsPtr(_:packetDescriptionsPointerOut:sizeOut:)](coremedia/cmsamplebuffergetaudiostreampacketdescriptionsptr(_:packetdescriptionspointerout:sizeout:).md)
