Open chw346 opened 9 months ago
Update: The problem has been temporarily fixed by changing the type of the variable "bestToWorstFormats" from WaveFormatExtensible[] to WaveFormat[] in the method body of WasapiOutRT:Init(), along with the correponding changes of the array member instantiations as needed. Not sure about any side-effects implied, but it just works in my specific project.
thanks for sharing your solution
Incorporated NAudio 2.1 in a UWP project with Visual Studio 2017 on Window 10 22H1. It works great with WASAPI exclusive mode in debug build. But it crashes in release build, the same problem with a side-loading package (which is code-signed).
The specific exception is: "Can't find supported format to use".
Also tried with NAudio 2.2.2 with Visual Studio 2022 on Window 11 22H2, the same result.
It seems that the AudioClient.IsFormatSupported(...) used in the WasapiOutRT.cs always failed with any given formats in release build, although it worked perfectly in debug build with the exact same input.
Update: This problem only happens when the WasapiOutRT object is initialized with a IOutputProvider with 32bit format, and the "Compile with .NET Native tool chain" option is enabled.