I am building a Windows Forms application that uses NAUDIO to record / play audio tracks.
During testing on Windows 7 we disabled all input devices (mics) and tried to record some audio.
There was a path through the code that attempted to record via the default input in WaveIn mode.
"An unhandled exception of type 'NAudio.MmException' occured in NAudio.dll
Aditional information: BadDeviceId calling waveInOpen
NAudio.MmException was unhandled
HResult=-2146233088
Message=BadDeviceId calling waveInOpen
Source=NAudio
StackTrace:
at NAudio.MmException.Try(MmResult result, String function) in c:\Users\mike\Documents\CSharp\CommonProjects\NAudio\Wave\MmeInterop\MmException.cs:line 40
at NAudio.Wave.WaveIn.OpenWaveInDevice() in c:\Users\mike\Documents\CSharp\CommonProjects\NAudio\Wave\WaveInputs\WaveIn.cs:line 185
at NAudio.Wave.WaveIn.StartRecording() in c:\Users\mike\Documents\CSharp\CommonProjects\NAudio\Wave\WaveInputs\WaveIn.cs:line 198
at xxxxxxxxxxClient.Announcements.MicRecordingControl.OnBtnRecordClick(Object sender, EventArgs e) in c:\Users\mike\Documents\CSharp\Applications\xxxxxxxxxxClient\xxxxxxxxxxClient\Announcements\MicRecordingControl.cs:line 237
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.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at xxxxxxxxxxClient.CPU.Run() in c:\Users\mike\Documents\CSharp\Applications\xxxxxxxxxxClient\xxxxxxxxxxClient\CPU.cs:line 83
at xxxxxxxxxxClient.Program.Main(String[] args) in c:\Users\mike\Documents\CSharp\Applications\xxxxxxxxxxClient\xxxxxxxxxxClient\Program.cs:line 27
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Subsequently - if the application is restarted it will no longer play audio! Even if it is pre-recorded.
The Windows Audio Mixer shows audio at the input but nothing at the output, while other inputs (applications) continue to function normally.
Even a reboot of the computer will not clear the problem.
Installing a new copy of the application will resolve the problem i.e. the new install works but the previous install continues to fail.
I tried adding a mic back to the system and recording audio again from the failed application instance. This appears to have recovered the application.
My question - is this a known behaviour of Windows 7? Is there a workaround or other solution that avoids reinstall or having to install a mic and attempt to record again from the same application?
(Obviously I will eliminate the path through the code as well...)
Comments: I'm not sure how NAudio could break the system this drastically. All we're doing is calling waveInOpen. Sounds more like a bad soundcard driver
During testing on Windows 7 we disabled all input devices (mics) and tried to record some audio.
There was a path through the code that attempted to record via the default input in WaveIn mode.
"An unhandled exception of type 'NAudio.MmException' occured in NAudio.dll
Aditional information: BadDeviceId calling waveInOpen
NAudio.MmException was unhandled
HResult=-2146233088
Message=BadDeviceId calling waveInOpen
Source=NAudio
StackTrace:
at NAudio.MmException.Try(MmResult result, String function) in c:\Users\mike\Documents\CSharp\CommonProjects\NAudio\Wave\MmeInterop\MmException.cs:line 40
at NAudio.Wave.WaveIn.OpenWaveInDevice() in c:\Users\mike\Documents\CSharp\CommonProjects\NAudio\Wave\WaveInputs\WaveIn.cs:line 185
at NAudio.Wave.WaveIn.StartRecording() in c:\Users\mike\Documents\CSharp\CommonProjects\NAudio\Wave\WaveInputs\WaveIn.cs:line 198
at xxxxxxxxxxClient.Announcements.MicRecordingControl.OnBtnRecordClick(Object sender, EventArgs e) in c:\Users\mike\Documents\CSharp\Applications\xxxxxxxxxxClient\xxxxxxxxxxClient\Announcements\MicRecordingControl.cs:line 237
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.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at xxxxxxxxxxClient.CPU.Run() in c:\Users\mike\Documents\CSharp\Applications\xxxxxxxxxxClient\xxxxxxxxxxClient\CPU.cs:line 83
at xxxxxxxxxxClient.Program.Main(String[] args) in c:\Users\mike\Documents\CSharp\Applications\xxxxxxxxxxClient\xxxxxxxxxxClient\Program.cs:line 27
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Subsequently - if the application is restarted it will no longer play audio! Even if it is pre-recorded.
The Windows Audio Mixer shows audio at the input but nothing at the output, while other inputs (applications) continue to function normally.
Even a reboot of the computer will not clear the problem.
Installing a new copy of the application will resolve the problem i.e. the new install works but the previous install continues to fail.
I tried adding a mic back to the system and recording audio again from the failed application instance. This appears to have recovered the application.
My question - is this a known behaviour of Windows 7? Is there a workaround or other solution that avoids reinstall or having to install a mic and attempt to record again from the same application?
(Obviously I will eliminate the path through the code as well...)
Comments: I'm not sure how NAudio could break the system this drastically. All we're doing is calling waveInOpen. Sounds more like a bad soundcard driver