none
IAudioEndpointVolume Interface and SetMute function RRS feed

  • Question

  • Hi,

    I have write a class wrapper to Vista API audion functions to control the master volume (level and mute).

    All functions of IAudioEndpointVolume Interface apper to work ok except the SetMute function.

    The problem apper to be the parameter pguidEventContext of type Guid.

    If I set the following value :

    Guid nullGuid;

    nullGuid = Guid.Empty;
            
    int retVal = iAudioEndpoint.SetMute(true, nullGuid);

    I obtain the error "value dows not fall within the expected range".

    If I set a different guid value I obtain the error "exception from HRESULT : 0x88890004".

    All other functions work ok with null guid. Only the SetMute function apper to have problems even if the Microsoft documentation allow to use the null value.

     

    [Guid("5CDF2C82-841E-4546-9722-0CF74078229A"),

    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

    public interface IAudioEndpointVolume

    {

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE RegisterControlChangeNotify(/* [in] */__in IAudioEndpointVolumeCallback *pNotify) = 0;

    int RegisterControlChangeNotify(IntPtr pNotify);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE UnregisterControlChangeNotify(/* [in] */ __in IAudioEndpointVolumeCallback *pNotify) = 0;

    int UnregisterControlChangeNotify(IntPtr pNotify);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetChannelCount(/* [out] */ __out UINT *pnChannelCount) = 0;

    int GetChannelCount(ref uint pnChannelCount);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetMasterVolumeLevel( /* [in] */ __in float fLevelDB,/* [unique][in] */ LPCGUID pguidEventContext) = 0;

    int SetMasterVolumeLevel(float fLevelDB, Guid pguidEventContext);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetMasterVolumeLevelScalar( /* [in] */ __in float fLevel,/* [unique][in] */ LPCGUID pguidEventContext) = 0;

    int SetMasterVolumeLevelScalar(float fLevel, Guid pguidEventContext);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetMasterVolumeLevel(/* [out] */ __out float *pfLevelDB) = 0;

    int GetMasterVolumeLevel(ref float pfLevelDB);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetMasterVolumeLevelScalar( /* [out] */ __out float *pfLevel) = 0;

    int GetMasterVolumeLevelScalar(ref float pfLevel);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetChannelVolumeLevel(/* [in] */__in UINT nChannel,float fLevelDB,/* [unique][in] */ LPCGUID pguidEventContext) = 0;

    int SetChannelVolumeLevel(uint nChannel, float fLevelDB, Guid pguidEventContext);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetChannelVolumeLevelScalar(/* [in] */ __in UINT nChannel,float fLevel,/* [unique][in] */ LPCGUID pguidEventContext) = 0;

    int SetChannelVolumeLevelScalar(uint nChannel, float fLevel, Guid pguidEventContext);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetChannelVolumeLevel(/* [in] */ __in UINT nChannel,/* [out] */__out float *pfLevelDB) = 0;

    int GetChannelVolumeLevel(uint nChannel, ref float pfLevelDB);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetChannelVolumeLevelScalar(/* [in] */__in UINT nChannel,/* [out] */__out float *pfLevel) = 0;

    int GetChannelVolumeLevelScalar(uint nChannel, ref float pfLevel);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetMute( /* [in] *__in BOOL bMute, /* [unique][in] */ LPCGUID pguidEventContext) = 0;

    int SetMute(bool bMute, Guid pguidEventContext);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetMute( /* [out] */ __out BOOL *pbMute) = 0;

    int GetMute(ref bool pbMute);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetVolumeStepInfo( /* [out] */ __out UINT *pnStep,/* [out] */__out UINT *pnStepCount) = 0;

    int GetVolumeStepInfo(ref uint pnStep, ref uint pnStepCount);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE VolumeStepUp( /* [unique][in] */ LPCGUID pguidEventContext) = 0;

    int VolumeStepUp(Guid pguidEventContext);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE VolumeStepDown(/* [unique][in] */ LPCGUID pguidEventContext) = 0;

    int VolumeStepDown(Guid pguidEventContext);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryHardwareSupport(/* [out] */ __out DWORD *pdwHardwareSupportMask) = 0;

    int QueryHardwareSupport(ref uint pdwHardwareSupportMask);

    //virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetVolumeRange( /* [out] */ __out float *pflVolumeMindB,/* [out] */ __out float *pflVolumeMaxdB,/* [out] */ __out float *pflVolumeIncrementdB) = 0;

    int GetVolumeRange(ref float pflVolumeMindB, ref float pflVolumeMaxdB, ref float pflVolumeIncrementdB);

    }

     

    Wednesday, February 28, 2007 3:56 PM

All replies

  • Please try using CoCreateInstance(IMMDeviceEnumerator) first, IMMDeviceEnumerator->GetDefaultAudioEndpoint(IMMDevice),then using  IMMDevice->activate(IAudioEndpointVolume). Right now, you can set endpoint's volume, volume level, mute.
    Thursday, March 29, 2007 10:28 AM