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

# SetShapeDmaAudioBuffer

> SetShapeDmaAudioBuffer

# SetShapeDmaAudioBuffer

设置 DMA 音频缓冲区。此为重载函数:一个函数接受虚拟指针,另一个接受物理地址。

## Syntax

```cpp theme={null}
HRESULT SetShapeDmaAudioBuffer(  
         SHAPE_DMA_CONTEXT* context,  
         APU_ADDRESS audioBuffer  
)  
```

### Parameters

*context*   \_Inout\_\
Type: [SHAPE\_DMA\_CONTEXT\*](/reference/audio/shapedmacontext/structs/shape_dma_context)

指向 [SHAPE\_DMA\_CONTEXT](/reference/audio/shapedmacontext/structs/shape_dma_context) 结构的指针。

*audioBuffer*   \_In\_\
Type: APU\_ADDRESS

缓冲区的物理地址。

### Return value

Type: HRESULT

HRESULT 成功或错误代码。

## Remarks

你可以通过确保音频缓冲区足够大且以规则时间间隔(与缓冲区大小相关)对数据进行流式传输来避免直接内存访问 (DMA) 命令被阻塞。例如,如果你一次流式传输四个硬件帧,请确保缓冲区中包含这些帧数的若干倍(至少为八帧的双缓冲),以便硬件能够在游戏的读指针之前写入。或者,你可以在提交下一个流程图之前强制清空缓冲区(消费、更新 DMA 读指针,然后提交流程图)。有关详细信息,请参阅 [SHAPE 概述](/build/console-features/audio/overviews/shape-overview) 中的[阻塞的命令](/build/console-features/audio/overviews/shape-overview#ID4EBGAC)。

## Requirements

**头文件:** shapedmacontext.h

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

## See also

[ShapeDmaContext](/reference/audio/shapedmacontext/shapedmacontext_members)


## Related topics

- [SetShapeDmaAudioBuffer 函数](/zh-CN/reference/audio/shapedmacontext/functions/setshapedmaaudiobuffer.md)
- [ShapeDmaContext](/zh-CN/reference/audio/shapedmacontext/shapedmacontext_members.md)
- [SetShapeDmaBufferFull](/zh-CN/reference/audio/shapedmacontext/functions/setshapedmabufferfull.md)
- [GetShapeDmaAudioBuffer](/zh-CN/reference/audio/shapedmacontext/functions/getshapedmaaudiobuffer.md)
- [SetShapePcmAudioBuffer](/zh-CN/reference/audio/shapepcmcontext/functions/setshapepcmaudiobuffer_2.md)
