Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set SetDuckingPreference #1135

Open
ReferenceType opened this issue Mar 10, 2024 · 1 comment
Open

Unable to set SetDuckingPreference #1135

ReferenceType opened this issue Mar 10, 2024 · 1 comment

Comments

@ReferenceType
Copy link

ReferenceType commented Mar 10, 2024

Hi
Im trying to do Stream Attenuation(Ducking), same as what skype does during call.
I am unable to set SetDuckingPreference on MMDevice, it doesnt change anything.

platform : Windows 11

What i did is :

defDevice.AudioSessionManager.OnSessionCreated += AudioSessionManagerOnSessionCreated;

private void AudioSessionManagerOnSessionCreated(object sender, IAudioSessionControl newSession)
{
     cc = newSession as IAudioSessionControl2;
    int hres =  cc.SetDuckingPreference(true);
}

where this device is used on WasapiOut.

Where i checked windows API for IAudioSessionControl2::SetDuckingPreference method (audiopolicy.h)
I dont know if you already implemented this or am i missing a hidden feature where i can activate Ducking.

Any help is appreciated.

Thanks

@ReferenceType
Copy link
Author

Ok so upon some trial and error it seems you cant enumerate device and select even if its same device.
it only works on default with communication role

var outputDevice = new MMDeviceEnumerator().GetDefaultAudioEndpoint(DataFlow.Render, Role.Communications);

if you enumerate for same device, it wont duck.

   foreach (MMDevice wasapi in enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active))
       ...

So i cant provide options for user.

If you know a workaround please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant