0

I'm trying to set the master volume in Windows 10 using C# WinForm and the CSCore.

I'm getting this error message when I call SimpleAudioVolume simpleaudiovolume = sessionmanager.GetSimpleAudioVolume( this._Guid, false ); and I'm guessing it's probably because I might not be using the correct guid.

CSCore.CoreAudioAPI.CoreAudioAPIException: 'IAudioSessionManager::GetSimpleAudioVolume caused an error: 0x88890001, "Unknown HRESULT".'

Can someone tell me what I'm doing wrong? Is this the property way to set the master volume?


    Guid _Guid = Guid.NewGuid();

    AudioClient audioclient = AudioClient.FromMMDevice( defaultdevice );
    AudioSessionManager sessionmanager = new AudioSessionManager( audioclient.BasePtr );
    SimpleAudioVolume simpleaudiovolume = sessionmanager.GetSimpleAudioVolume( this._Guid, false );
    simpleaudiovolume.SetMasterVolumeNative( 0.02f, this._Guid );


    public static MMDevice GetDefaultRenderDevice()
    {
        using ( MMDeviceEnumerator enumerator = new MMDeviceEnumerator() )
        {
            return enumerator.GetDefaultAudioEndpoint( DataFlow.Render, Role.Console );
        }
    }
Kathy Judd
  • 713
  • 3
  • 9
  • 18

0 Answers0