> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AcpHalAllocateShapeContexts

> AcpHalAllocateShapeContexts

Allocates context arrays for the Scalable Hardware Audio Processing Engine (SHAPE) and XBOX Media Audio (XMA).

## Syntax

```cpp theme={null}
HRESULT AcpHalAllocateShapeContexts(  
         SHAPE_CONTEXTS* contextArrays  
)  
```

### Parameters

*contextArrays*   \_Inout\_\
Type: [SHAPE\_CONTEXTS\*](https://docs.xbox.com/reference/audio/acphal/structs/shape_contexts.md)

On input, the context should contain the requested size of the context arrays. If the function succeeds, the context is populated with the allocated arrays. Refer to the [SHAPE\_DMA\_CONTEXT](https://docs.xbox.com/reference/audio/shapedmacontext/structs/shape_dma_context.md), [SHAPE\_EQCOMP\_CONTEXT](https://docs.xbox.com/reference/audio/shapeeqcompcontext/structs/shape_eqcomp_context.md), [SHAPE\_FILTVOL\_CONTEXT](https://docs.xbox.com/reference/audio/shapefiltvolcontext/structs/shape_filtvol_context.md), [SHAPE\_PCM\_CONTEXT](https://docs.xbox.com/reference/audio/shapepcmcontext/structs/shape_pcm_context.md), [SHAPE\_SRC\_CONTEXT](https://docs.xbox.com/reference/audio/shapesrccontext/structs/shape_src_context.md), and [SHAPE\_XMA\_CONTEXT](https://docs.xbox.com/reference/audio/shapexmacontext/structs/shape_xma_context.md) structures.

### Return value

Type: HRESULT

If the method succeeds, it returns `S_OK`. If the method fails, it returns one of the following codes (partial list):

| Return code | Description |
| - | - |
| E\_INVALIDARG | One or more of the arguments are invalid. |
| E\_OUTOFMEMORY | Memory allocation failed. |
| ACP\_E\_ALREADY\_ALLOCATED | The context arrays are already allocated. |

## Remarks

Call this method to allocate contexts for an Audio Control Processor (ACP) client before calling [AcpHalCreate](https://docs.xbox.com/reference/audio/acphal/functions/acphalcreate.md).

Unless there's a subsequent call to [AcpHalReleaseShapeContexts](https://docs.xbox.com/reference/audio/acphal/functions/acphalreleaseshapecontexts.md), this method should be called only once.

The number of Sample Rate Convertor (SRC) contexts must equal the sum of the number of pulse-code modulation (PCM) contexts and the number of XMA contexts.

## Requirements

**Header:** acphal.h

**Library:** acphal.lib

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

## See also

[AcpHalReleaseShapeContexts](https://docs.xbox.com/reference/audio/acphal/functions/acphalreleaseshapecontexts.md)\
[AcpHalCreate](https://docs.xbox.com/reference/audio/acphal/functions/acphalcreate.md)\
[AcpHal](https://docs.xbox.com/reference/audio/acphal/acphal_members.md)


## Related topics

- [AcpHal](https://docs.xbox.com/reference/audio/acphal/acphal_members.md)
- [AcpHalReleaseShapeContexts](https://docs.xbox.com/reference/audio/acphal/functions/acphalreleaseshapecontexts.md)
- [SHAPE_CONTEXTS](https://docs.xbox.com/reference/audio/acphal/structs/shape_contexts.md)
- [AcpHalCreate](https://docs.xbox.com/reference/audio/acphal/functions/acphalcreate.md)
- [IAcpHal::Connect](https://docs.xbox.com/reference/audio/acphal/interfaces/IAcpHal/methods/iacphal_connect.md)
