> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.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\*](/reference/audio/acphal/structs/shape_contexts)

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

### 返回值

类型:HRESULT

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

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

## 备注

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

除非之后调用了 [AcpHalReleaseShapeContexts](/reference/audio/acphal/functions/acphalreleaseshapecontexts),否则此方法只应调用一次。

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

## 要求

**头文件:** acphal.h

**库:** acphal.lib

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

## 另请参阅

[AcpHalReleaseShapeContexts](/reference/audio/acphal/functions/acphalreleaseshapecontexts)\
[AcpHalCreate](/reference/audio/acphal/functions/acphalcreate)\
[AcpHal](/reference/audio/acphal/acphal_members)


## Related topics

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