IAcousticEchoCancellationControl::SetEchoCancellationRenderEndpoint 方法 (audioclient.h)

设置音频呈现终结点,该终结点应用作 AEC) 声学回声消除的参考流 (。

语法

HRESULT SetEchoCancellationRenderEndpoint(
  LPCWSTR endpointId
);

参数

endpointId

应用作 AEC 引用流的终结点的终结点 ID。 设置无效的呈现设备 ID 将失败并出现E_INVALIDARG。 将该值设置为 NULL 将导致 Windows 使用自己的算法来选取环回引用设备

返回值

返回一个 HRESULT 值,包括以下内容:

说明
S_OK 成功。
E_INVALIDARG endpointId 值无效。

注解

以下示例演示 IAcousticEchoCancellationControl 接口的用法。 调用 IAudioClient::GetService,传入 IAcousticEchoCancellationControl 接口的 IID。 如果成功,捕获终结点支持控制 AEC 的环回引用终结点。 请注意,终结点可能支持 AEC,但可能不支持控制 AEC 的环回引用终结点。 调用 SetEchoCancellationRenderEndpoint 以设置 AEC 的引用流。 如果调用 GetService 失败并 出现E_NOINTERFACE,则终结点上的 AEC 效果 (如果支持) ,则不允许控制环回引用终结点。

wil::com_ptr_nothrow<IAudioClient> audioClient;

RETURN_IF_FAILED(device->Activate(_uuidof(IAudioClient), CLSCTX_INPROC_SERVER, nullptr, (void **)&audioClient));

// Call Initialize before calling GetService
// Implementation of IAudioClient::Initialize has been omitted from this sample for brevity.

RETURN_IF_FAILED(audioClient->Initialize(…));

// If the capture endpoint supports acoustic echo cancellation (AEC), pass it the endpoint id of the
// audio render endpoint that should be used as the reference stream. If the capture endpoint does not
// support AEC, the GetService call fails with E_NOINTERFACE, so errors from GetService are not
// treated as fatal.

wil::com_ptr_nothrow<IAcousticEchoCancellationControl> audioAcousticEchoCancellationControl;

if (SUCCEEDED(audioClient->GetService(IID_PPV_ARGS(&audioAcousticEchoCancellationControl))))
{

RETURN_IF_FAILED(audioAcousticEchoCancellationControl-> SetEchoCancellationRenderEndpoint(endpointIdOfReferenceAudioStream));

}

要求

要求
最低受支持的客户端 Windows 内部版本 22621
标头 audioclient.h