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

# XDspActivate

> XDspActivate

# XDspActivate

從集區取得可用的處理資源來啟用 XDSP 串流。每個 XDSP 用戶端最多只能啟用 256 個串流。

## 語法

```cpp theme={null}
HRESULT XDspActivate(  
         XDspClientHandle clientHandle,  
         XDspActivationParameters* params,  
         XDspStatus** status,  
         XDspStreamHandle* streamHandle  
)  
```

### 參數

*clientHandle*   \_In\_\
類型:[XDspClientHandle](/zh-TW/reference/audio/xdspaudio/handles/xdspclienthandle)

從呼叫 XDspConnect 取得的有效 XDSP 用戶端控制代碼。

*params*   \_In\_\
類型:[XDspActivationParameters\*](/zh-TW/reference/audio/xdspaudio/structs/xdspactivationparameters)

[XDspActivationParameters](/zh-TW/reference/audio/xdspaudio/structs/xdspactivationparameters) 結構的指標。

*status*   \_Outptr\_\
類型:[XDspStatus\*\*](/zh-TW/reference/audio/xdspaudio/structs/xdspstatus)

[XDspStatus](/zh-TW/reference/audio/xdspaudio/structs/xdspstatus) 結構的指標。如需其他詳細資料,請參閱**備註**一節。

*streamHandle*   \_Outptr\_\
類型:[XDspStreamHandle\*](/zh-TW/reference/audio/xdspaudio/handles/xdspstreamhandle)

如果呼叫成功,則為有效的 [XDspStreamHandle](/zh-TW/reference/audio/xdspaudio/handles/xdspstreamhandle)。如需其他詳細資料,請參閱**備註**一節。

### 傳回值

類型:HRESULT

如果方法成功,會傳回 S\_OK。如果方法失敗,會傳回下列其中一個代碼 (部分清單):

| 傳回碼 | 描述 |
| - | - |
| E\_POINTER | 無效的指標。 |
| E\_INVALIDARG | 一或多個引數無效。 |
| XDSP\_E\_NO\_DEVICE\_RESOURCES | 沒有可用的 XDSP 裝置資源來處理您的要求。 |
| XDSP\_E\_INVALID\_IMPULSE\_RESPONSE\_LENGTH | 提供的脈衝回應長度無效。如果提供的 [impulseResponseLengthInFloats](/zh-TW/reference/audio/xdspaudio/structs/xdspactivationparameters) 小於 (`9 * blockSize * 2`) 或大於 16 秒 (`16 * 48000 * 2`),就可能發生此錯誤。 |

## 備註

此呼叫速度很快,因為它是從集區取得資源,而不是配置資源。

呼叫端必須為 XDSP 串流指定要執行的 [XDspProcessType](/zh-TW/reference/audio/xdspaudio/enums/xdspprocesstype)。XDSP 串流的執行個體在其存留期間只能使用一種處理類型。若要執行兩種以上不同的處理類型,必須具現化兩個以上的 XDSP 串流執行個體。

在 [XDspActivationParameters](/zh-TW/reference/audio/xdspaudio/structs/xdspactivationparameters) 結構中,呼叫端必須指定下列項目:

* 啟用選項。
* 每個命令中將處理的框架數目,也就是輸入和輸出的框架數目。
* 串流的聲道數目。僅支援單聲道和立體聲輸入串流。
* 對於 [XDspProcessType::Convolution](/zh-TW/reference/audio/xdspaudio/enums/xdspprocesstype) 處理類型,指定以 float 為單位的脈衝回應長度。
* 對於 [XDspProcessType::Convolution](/zh-TW/reference/audio/xdspaudio/enums/xdspprocesstype) 處理類型,指定以頻域值表示的脈衝回應。

如果呼叫成功,將會傳回有效的 [XDspStreamHandle](/zh-TW/reference/audio/xdspaudio/handles/xdspstreamhandle),以便針對此串流搭配其他呼叫 ([XDspSubmitCommand](/zh-TW/reference/audio/xdspaudio/functions/xdspsubmitcommand)、[XDspSubmitCommandWithEnvelope](/zh-TW/reference/audio/xdspaudio/functions/xdspsubmitcommandwithenvelope)、[XDspDeactivate](/zh-TW/reference/audio/xdspaudio/functions/xdspdeactivate)) 使用。此外,如果此呼叫成功,它會傳回 [XDspStatus](/zh-TW/reference/audio/xdspaudio/structs/xdspstatus) 的指標,可用來檢查已提交命令的狀態。

這應該用來判斷已處理的最新命令,以及已提交命令的結果是否已準備好可供取用。
[XDspStatus](/zh-TW/reference/audio/xdspaudio/structs/xdspstatus) 也包含其所代表 XDSP 串流最後提交至硬體之命令的序號,以及第一個失敗命令的序號。在摺積處理的情況下,呼叫端可以在此呼叫傳回後釋放脈衝回應記憶體。

## 需求

**標頭:** XDspAudio.h

**程式庫:** Chad.lib

**支援的平台:** XBOX Series X|S

## 概念文件

* [使用 XDSP API 進行含 Envelope 的單一串流 Convolution 的概觀](/zh-TW/build/console-features/audio/overviews/xdsp-overview-single-stream-convolution-with-envelope)
* [使用 XDSP API 進行單一串流 Convolution 的概觀](/zh-TW/build/console-features/audio/overviews/xdsp-overview-single-stream-convolution)
* [XDSP 概觀](/zh-TW/build/console-features/audio/overviews/xdsp-overview)

## 另請參閱

[XDSP](/zh-TW/reference/audio/xdspaudio/xdspaudio_members)\
[XDSP 錯誤](/zh-TW/reference/audio/xdspaudio/enums/xdsperrors)\
[使用 XDSP API 進行單一串流 Convolution 的概觀](/zh-TW/build/console-features/audio/overviews/xdsp-overview-single-stream-convolution)\
[使用 XDSP API 進行單一串流 FFT/IFFT 的概觀](/zh-TW/build/console-features/audio/overviews/xdsp-overview-single-stream-fft-ifft)\
[使用 XDSP API 進行含 Envelope 的單一串流 Convolution 的概觀](/zh-TW/build/console-features/audio/overviews/xdsp-overview-single-stream-convolution-with-envelope)


## Related topics

- [XDspActivate](/reference/audio/xdspaudio/functions/xdspactivate.md)
- [XDspDeactivate](/reference/audio/xdspaudio/functions/xdspdeactivate.md)
