This project has moved. For the latest updates, please go here.

Value does not fall within the expected range (Init)

Jul 26, 2010 at 3:48 AM

Hey folks,

 

I get the following exception "Value does not fall within the expected range" on certain client machines when calling Init(). I have no idea what the error "The value does not fall within the expected range." On my development PC, the code executes just fine.

 

The error happens at this line:

waveOut.Init(waveProvider);

 

waveProvider is a custom implementation of a wave provider class that extends the NAudio WaveStream object. This is found in the NSpeex audio library (WPF demo).

 

Originally, I thought that this may fail due to the sound devices not being enabled and/or unmuted, but all devices were enabled and unmuted. The client machine in question is running Vista Ultimate, and this has been tested on other Vista machines without fail.

 

The stack trace is below and is as follows. Thanks in advance!

 

 

 

************** Exception Text **************
System.ArgumentException: Value does not fall within the expected range.
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at NAudio.CoreAudioApi.AudioClient.Initialize(AudioClientShareMode shareMode, AudioClientStreamFlags streamFlags, Int64 bufferDuration, Int64 periodicity, WaveFormat waveFormat, Guid audioSessionGuid)
   at NAudio.Wave.WasapiOut.Init(IWaveProvider waveStream)
   at ElyteNetTest.ElyteVOIP..ctor() in C:\Users\Jimmy\Documents\Visual Studio 2008\Projects\EVPN\ElyteNetTest\ElyteVOIP.cs:line 144
   at ElyteNetTest.netTests..ctor() in C:\Users\Jimmy\Documents\Visual Studio 2008\Projects\EVPN\ElyteNetTest\netTests.cs:line 29
   at ElyteNetTest.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\Jimmy\Documents\Visual Studio 2008\Projects\EVPN\ElyteNetTest\Form1.cs:line 176
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Coordinator
Aug 11, 2010 at 10:58 AM

what are the bufferDuration and periodicity values?