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

# GetXmaDecodePositionForSample

> GetXmaDecodePositionForSample

# GetXmaDecodePositionForSample

获取所需数据，用于让解码器从相对于指定的 XBOX Media Audio (XMA) 块开头的指定采样位置开始生成音频。

## 语法

```cpp theme={null}
HRESULT GetXmaDecodePositionForSample(  
         const BYTE* pXmaData,  
         DWORD nXmaDataBytes,  
         DWORD nStreamIndex,  
         DWORD nDesiredSample,  
         DWORD* pnBitOffset,  
         DWORD* pnSubFrame  
)  
```

### 参数

*pXmaData*   \_In\_bytecount\_(nXmaDataBytes)\
类型：BYTE\*

指向 XMA 块的指针。

*nXmaDataBytes*   \
类型：DWORD

pXmaData 的大小（以字节为单位）。

*nStreamIndex*   \
类型：DWORD

要在其中查找的流。

*nDesiredSample*   \
类型：DWORD

要查找的采样。

*pnBitOffset*   \_Out\_\
类型：DWORD\*

返回包含所查找采样的帧在 pXmaData 中的位偏移量。

*pnSubFrame*   \_Out\_\
类型：DWORD\*

返回包含该采样的子帧。

### 返回值

类型：HRESULT

成功 `S_OK` 或错误 `E_FAIL` 代码。

## 备注

此函数获取所需数据，用于让解码器从相对于给定 XMA 块开头的给定采样位置开始生成音频。这包括相应帧的位偏移量以及该帧内正确的子帧。这些数据可直接传递给 `XMAPlaybackSetDecodePosition` 函数。有关 XMA2 的详细信息，请参阅 [XMA2 概述](/build/console-features/audio/overviews/xma2-overview)。有关 XBOX One 音频架构的概述，请参阅**未来之声**：[XBOX One 中的音频架构](/build/console-features/audio/overviews/xbox-one-audio-architecture)。

## 要求

**头文件：** xma2defs.h

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

## 另请参阅

[xma2defs](/reference/audio/xma2defs/xma2defs_members)


## Related topics

- [XMA2Defs](/zh-CN/reference/audio/xma2defs/xma2defs_members.md)
- [GetXmaFrameBitPosition](/zh-CN/reference/audio/xma2defs/functions/getxmaframebitposition.md)
- [GetLastXmaFrameBitPosition](/zh-CN/reference/audio/xma2defs/functions/getlastxmaframebitposition.md)
- [GetShapeXmaNumSubframesToDecode](/zh-CN/reference/audio/shapexmacontext/functions/getshapexmanumsubframestodecode.md)
- [SetSamplePositions](/zh-CN/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist1/methods/id3d12graphicscommandlist1_setsamplepositions_public.md)
