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.23k stars 458 forks source link

WasapiOut not working with Windows 10 final #11

Closed DanielGilbert closed 9 years ago

DanielGilbert commented 9 years ago

Maybe I'm missing something, but I cannot Initialize the WasapiOut, because I receive an "OutOfRangeException" for the parameter "value":

at CSCore.SoundOut.WasapiOut.InitializeInternal() at CSCore.SoundOut.WasapiOut.Initialize(IWaveSource source)

It occurs, because in the InitializeInternal Method, the "Latency" parameter gets set to 0. That is because of the _audioClient.StreamLatency being 0. This only happens on the Release Version of Windows 10. I haven't had the Problem on Windows 7, 8, 8.1 and Windows 10 Insider Preview .

The error even occurs on a clean install of Windows 10. Any idea what could be the reason for this behaviour?

I'm initializing the WasapiOut with a WriteableBufferingSource, based on a WasapiLoopbackCapture on another device.

filoe commented 9 years ago

Could you please provide some more details? I would need to know all relevant parameters of the soundout class.

DanielGilbert commented 9 years ago

Hi - I'm not quite sure what you mean by "parameters", so I wrote a small sample application. :)

wasapi_sample

This application simply takes the output on the default audio device, and loops it to the audio device, given by the id that is entered in the above textbox. (So you need at least two Audioendpoints for this sample, and you should find the right id.) Now, when running this app on Windows 7 (by pressing "Start"), everything works as expected. Running it on Windows 10, it catches the "Latency"-Exception.

You can try the example, if you have Windows 10 at hand:

http://danielgilbert.de/SimpleWasapiLoopback.zip

(it's built using Visual Studio 2015 and .NET 4.5.2, using NuGet to get the CSCore Pre-Release)

filoe commented 9 years ago

Thanks, i am going to take a look at it. EDIT: I updated to Windows 10. You're right the "problem" is that https://msdn.microsoft.com/en-us/library/windows/desktop/dd370874(v=vs.85).aspx returns zero. Could not find any remarks why. Going to try to figure out how to solve the issue.

DanielGilbert commented 9 years ago

Thanks for the fast workaround - just had the chance to check it, and it's working perfect with Windows 10 now. However, strange from Microsoft.