The SetMasterVolumeLevel method sets the master volume level, in decibels, of the audio stream that enters or leaves the audio endpoint device.
public:
HRESULT SetMasterVolumeLevel(
float fLevelDB,
LPCGUID pguidEventContext
)
fLevelDB
Type: float
[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
Type: LPCGUID
[in] This parameter is currently unused, and must be NULL.
Type: HRESULT
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 code | Description |
|---|---|
| E_INVALIDARG | Parameter fLevelDB lies outside of the volume range supported by the device. |
| E_OUTOFMEMORY | 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.
Header: Declared in endpointvolume.h.
Library: Use MMDevApi.lib.