ISpatialAudioClient::ActivateSpatialAudioStream 方法 (spatialaudioclient.h)

使用空间音频流激活结构之一激活和初始化空间音频流。

语法

HRESULT ActivateSpatialAudioStream(
  [in]  const PROPVARIANT *activationParams,
  [in]  REFIID            riid,
  [out] void              **stream
);

参数

[in] activationParams

定义空间音频流的激活参数的结构。 vt 字段应设置为 VT_BLOB blob 字段应填充 SpatialAudioObjectRenderStreamActivationParamsSpatialAudioObjectRenderStreamForMetadataActivationParams

[in] riid

要激活的空间音频流接口的 UUID。

[out] stream

指向接收激活的空间音频接口的指针的指针。

返回值

如果该方法成功,则它会返回 S_OK。

注解

此方法支持激活以下空间音频流接口:

ISpatialAudioObjectRenderStream

ISpatialAudioObjectRenderStreamForMetadata

示例

Microsoft::WRL::ComPtr<ISpatialAudioClient> spatialAudioClient;

// Activate ISpatialAudioClient on the desired audio-device 
hr = defaultDevice->Activate(__uuidof(ISpatialAudioClient), CLSCTX_INPROC_SERVER, nullptr, (void**)&spatialAudioClient);

hr = spatialAudioClient->IsAudioObjectFormatSupported(&format);

// Create the event that will be used to signal the client for more data
HANDLE bufferCompletionEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);

SpatialAudioObjectRenderStreamActivationParams streamParams;
streamParams.ObjectFormat = &format;
streamParams.StaticObjectTypeMask = ChannelMask_Stereo;
streamParams.MinDynamicObjectCount = 0;
streamParams.MaxDynamicObjectCount = 0;
streamParams.Category = AudioCategory_SoundEffects;
streamParams.EventHandle = bufferCompletionEvent;
streamParams.NotifyObject = nullptr;

PROPVARIANT activationParams;
PropVariantInit(&activationParams);
activationParams.vt = VT_BLOB;
activationParams.blob.cbSize = sizeof(streamParams);
activationParams.blob.pBlobData = reinterpret_cast<BYTE *>(&streamParams);

Microsoft::WRL::ComPtr<ISpatialAudioObjectRenderStream> spatialAudioStream;
hr = spatialAudioClient->ActivateSpatialAudioStream(&activationParams, __uuidof(spatialAudioStream), (void**)&spatialAudioStream);

要求

   
目标平台 Windows
标头 spatialaudioclient.h

另请参阅

ISpatialAudioClient

SpatialAudioObjectRenderStreamActivationParams

SpatialAudioObjectRenderStreamForMetadataActivationParams