filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.14k stars 450 forks source link

How to prevent WasapiOut to change Device when soundouput changes #482

Open steam3d opened 9 months ago

steam3d commented 9 months ago

I got strange behaviour. I setup the WasapiOut like this:

_soundOut = new WasapiOut() { Latency = 100, Device = device};

if device selects as current playback device (DefaultDevice) then when I switch device to another device. The audio will follow to another device and will be played there. But if device selects as not current playback device then when I switch device to another device. The audio will not follow to another device and will not be played there instead of this it will played at the device.

So I found option StreamRoutingOptions = StreamRoutingOptions.Disabled and changed WaspiOut like this:

_soundOut = new WasapiOut() { Latency = 100, Device = device, StreamRoutingOptions = StreamRoutingOptions.Disabled};

And again I have the same behavior as I described above.

So how can I prevent switching device when user change sound out? I want to play audio only on the device.