public static MorphicResult <AudioEndpoint, WindowsComError> GetDefaultAudioOutputEndpoint() { // get a reference to our default output device var createDeviceEnumeratorResult = MMDeviceEnumerator.CreateNew(); if (createDeviceEnumeratorResult.IsError == true) { return(MorphicResult.ErrorResult(createDeviceEnumeratorResult.Error !)); } var mmDeviceEnumerator = createDeviceEnumeratorResult.Value !; // // NOTE: .NET should automatically release the defaultAudioOutputEndpoint var getDefaultAudioEndpointResult = mmDeviceEnumerator.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia); if (getDefaultAudioEndpointResult.IsError == true) { return(MorphicResult.ErrorResult(getDefaultAudioEndpointResult.Error !)); } var defaultAudioOutputEndpoint = getDefaultAudioEndpointResult.Value !; // activate the endpoint so we can read/write its volume and mute state, etc. Guid IID_IAudioEndpointVolume = new Guid("5CDF2C82-841E-4546-9722-0CF74078229A"); var activateResult = defaultAudioOutputEndpoint.Activate(IID_IAudioEndpointVolume, CLSCTX.CLSCTX_INPROC_SERVER); if (activateResult.IsError == true) { return(MorphicResult.ErrorResult(activateResult.Error !)); } var audioEndpointVolumeAsObject = activateResult.Value !; var audioEndpointVolume = (IAudioEndpointVolume)audioEndpointVolumeAsObject; var result = new AudioEndpoint(audioEndpointVolume); return(MorphicResult.OkResult(result)); }