IAudioEndpointVolume::SetMasterVolumeLevel method

The SetMasterVolumeLevel method sets the master volume level, in decibels, of the audio stream that enters or leaves the audio endpoint device.


HRESULT SetMasterVolumeLevel(
  [infloat   fLevelDB,
  [in] LPCGUID pguidEventContext


fLevelDB [in]

The new master volume level in decibels. To obtain the range and granularity of the volume levels that can be set by this method, call the IAudioEndpointVolume::GetVolumeRange method.

pguidEventContext [in]

Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the SetMasterVolumeLevel call changes the volume level of the endpoint, all clients that have registered IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine receives the context GUID value GUID_NULL.

Return value

If the method succeeds, it returns S_OK. If it fails, possible return codes include, but are not limited to, the values shown in the following table.

Return codeDescription

Parameter fLevelDB lies outside of the volume range supported by the device.


Out of memory.



If volume level fLevelDB falls outside of the volume range reported by the IAudioEndpointVolume::GetVolumeRange method, the SetMasterVolumeLevel call fails and returns error code E_INVALIDARG.


Minimum supported client

Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 [desktop apps | Windows Store apps]



See also

IAudioEndpointVolume Interface
IAudioEndpointVolumeCallback Interface