共用方式為


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