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

# XGameStreamingGetAssociatedFrame

> XGameStreamingGetAssociatedFrame

# XGameStreamingGetAssociatedFrame

<Info>**已弃用。** 此 API 从 2604 GDK 版本开始已弃用，将在未来的 GDK 版本中删除。没有替代 API：游戏应改用 [XGameStreamingGetStreamAddedLatency](/reference/system/xgamestreaming/functions/xgamestreaminggetstreamaddedlatency) 进行延迟感知的游戏调整。</Info>

从特定的输入读取中获取帧管道令牌。

## 语法

```cpp theme={null}
HRESULT XGameStreamingGetAssociatedFrame(  
         IGameInputReading* gamepadReading,  
         D3D12XBOX_FRAME_PIPELINE_TOKEN* framePipelineToken  
)  
```

### 参数

*gamepadReading*   \_In\_\
类型：IGameInputReading\*

正在查询的游戏板读取。

*framePipelineToken*   \_Out\_\
类型：D3D12XBOX\_FRAME\_PIPELINE\_TOKEN\*

与玩家进行输入时在客户端设备上显示的帧关联的帧管道令牌。此管道令牌对应于游戏呈现并发送到客户端设备时的 PresentX 调用。

### 返回值

类型：HRESULT

如果成功，则返回 **S\_OK**；否则返回错误代码。

#### 潜在错误

| 错误代码                                         | 错误值        | 错误原因                                                                                                                                       |
| -------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| E\_GAMESTREAMING\_NOT\_INITIALIZED           | 0x89245400 | XGameStreaming 运行时尚未初始化。在调用其他 API 之前，请先调用 [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize)。 |
| E\_GAMESTREAMING\_NO\_DATA                   | 0x89245402 | 请求的数据不可用。数据可能稍后可用。                                                                                                                         |
| E\_GAMESTREAMING\_NOT\_STREAMING\_CONTROLLER | 0x89245404 | 当前读取并非来自流式处理控制器。                                                                                                                           |

## 备注

当玩家正在流式播放游戏时，如果游戏需要根据在玩家输入时在其设备上显示的特定帧来更改游戏行为，则可以使用 `XGameStreamingGetAssociatedFrame`。

这将允许游戏根据玩家在输入时看到的帧而不是当前帧做出模拟决策。

`XGameStreamingGetAssociatedFrame` 只能在创建新的输入读取时为游戏提供有关正在显示的帧的信息。如果游戏需要确定在玩家未进行输入时显示的内容，则游戏应使用 [XGameStreamingGetLastFrameDisplayed](/reference/system/xgamestreaming/functions/xgamestreaminggetlastframedisplayed)。

## 示例

```C++ theme={null}
// In this example, when processing input, the game would like to pass along the frame 
// that was being displayed to the player at the time of input so that their simulation
// engine can take that into account.

// The framePipelineToken was initially captured at the callback of WaitFrameEventX

void Game::Update(DX::StepTimer const& timer)
{
    IGameInputReading* reading;
    if (SUCCEEDED(g_gameInput->GetCurrentReading(GameInputKindGamepad, g_gamepad, &reading)))
    {
        D3D12XBOX_FRAME_PIPELINE_TOKEN framePipelineToken = D3D12XBOX_FRAME_PIPELINE_TOKEN_NULL;        

        if SUCCEEDED(XGameStreamingGetAssociatedFrame(&reading, &framePipelineToken)) 
        {
            SimulateBasedOnInputAndFrameDisplayed(reading, framePipelineToken);
        }
        else 
        {
            // simulate based on current frame
            SimulateBasedOnInput(reading);
        }

        reading->Release();
    }
}

```

## 要求

**标头：** xgamestreaming.h

**库：** xgameruntime.lib

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

## 概念性文档

* [游戏流式处理延迟补偿深入探究](/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive)

## 另请参阅

[XGameStreamingGetLastFrameDisplayed](/reference/system/xgamestreaming/functions/xgamestreaminggetlastframedisplayed)\
[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members#Latency)\
[游戏流式处理延迟补偿概述](/build/core-features/common/game-streaming/game-streaming-latency-compensation-overview)


## Related topics

- [XGameStreamingGetLastFrameDisplayed](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetlastframedisplayed.md)
- [XGameStreaming](/zh-CN/reference/system/xgamestreaming/xgamestreaming_members.md)
- [游戏串流延迟补偿深入探讨](/zh-CN/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive.md)
- [XGameStreamingGetStreamAddedLatency](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetstreamaddedlatency.md)
- [XGameStreamingGetClients](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetclients.md)
