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

# GetShapeDmaReadPointer

> GetShapeDmaReadPointer

# GetShapeDmaReadPointer

获取直接内存访问 (DMA) 读指针。

## Syntax

```cpp theme={null}
UINT32 GetShapeDmaReadPointer(  
         const SHAPE_DMA_CONTEXT* context  
)  
```

### Parameters

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

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

### Return value

Type: UINT32

读指针,以帧(128 采样块)为单位。

## Remarks

若要计算 DMA 缓冲区的大小,请使用以下公式:

```cpp theme={null}
fullBufferSizeInBytes = 128 * 4 * numChannels * numFrames  
```

读写指针按以下方式递增:

```cpp theme={null}
readPointer = (readPointer + 1) % numFrames 

writePointer = (writePointer + 1) % numFrames  
```

音频缓冲区内的地址按以下方式计算:

```cpp theme={null}
readAddress = audioBuffer + (128 * 4 * ((readPointer * numChannels) + channel))   

writeAddress = audioBuffer + (128 * 4 * ((writePointer * numChannels) + channel))  
```

你可以通过确保音频缓冲区足够大且以规则时间间隔(与缓冲区大小相关)对数据进行流式传输来避免 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

- [ShapeDmaContext](/zh-CN/reference/audio/shapedmacontext/shapedmacontext_members.md)
- [SetShapeDmaReadPointer](/zh-CN/reference/audio/shapedmacontext/functions/setshapedmareadpointer.md)
- [IncrementShapeDmaReadPointer](/zh-CN/reference/audio/shapedmacontext/functions/incrementshapedmareadpointer.md)
- [GetShapePcmReadPointer](/zh-CN/reference/audio/shapepcmcontext/functions/getshapepcmreadpointer.md)
- [GetShapeDmaWritePointer](/zh-CN/reference/audio/shapedmacontext/functions/getshapedmawritepointer.md)
