> ## 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

# AcpHalAllocateShapeContexts

为可伸缩硬件音频处理引擎(Scalable Hardware Audio Processing Engine,SHAPE)和 XBOX Media Audio(XMA)分配上下文数组。

## 语法

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

### 参数

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

传入时,该上下文应包含所请求的上下文数组大小。如果函数成功,该上下文将被填充为已分配的数组。请参阅 [SHAPE\_DMA\_CONTEXT](https://docs.xbox.com/zh-CN/reference/audio/shapedmacontext/structs/shape_dma_context.md)、[SHAPE\_EQCOMP\_CONTEXT](https://docs.xbox.com/zh-CN/reference/audio/shapeeqcompcontext/structs/shape_eqcomp_context.md)、[SHAPE\_FILTVOL\_CONTEXT](https://docs.xbox.com/zh-CN/reference/audio/shapefiltvolcontext/structs/shape_filtvol_context.md)、[SHAPE\_PCM\_CONTEXT](https://docs.xbox.com/zh-CN/reference/audio/shapepcmcontext/structs/shape_pcm_context.md)、[SHAPE\_SRC\_CONTEXT](https://docs.xbox.com/zh-CN/reference/audio/shapesrccontext/structs/shape_src_context.md) 和 [SHAPE\_XMA\_CONTEXT](https://docs.xbox.com/zh-CN/reference/audio/shapexmacontext/structs/shape_xma_context.md) 结构体。

### 返回值

类型:HRESULT

如果方法成功,则返回 `S_OK`。如果方法失败,则返回以下代码之一(部分列表):

| 返回代码 | 描述 |
| - | - |
| E\_INVALIDARG | 一个或多个参数无效。 |
| E\_OUTOFMEMORY | 内存分配失败。 |
| ACP\_E\_ALREADY\_ALLOCATED | 上下文数组已被分配。 |

## 备注

在调用 [AcpHalCreate](https://docs.xbox.com/zh-CN/reference/audio/acphal/functions/acphalcreate.md) 之前,调用此方法为音频控制处理器(Audio Control Processor,ACP)客户端分配上下文。

除非之后调用了 [AcpHalReleaseShapeContexts](https://docs.xbox.com/zh-CN/reference/audio/acphal/functions/acphalreleaseshapecontexts.md),否则此方法只应调用一次。

采样率转换器(Sample Rate Convertor,SRC)上下文的数量必须等于脉冲编码调制(PCM)上下文数量与 XMA 上下文数量之和。

## 要求

**头文件:** acphal.h

**库:** acphal.lib

**支持的平台:** XBOX One 系列主机和 XBOX Series 主机

## 另请参阅

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


## Related topics

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