When I disable and re-enable microphone on system level the next one calling of WaveIn.StartRecording ends up with MmException: NoDriver calling waveInPrepareHeader.
NAudio.MmException: NoDriver calling waveInPrepareHeader
v NAudio.Wave.WaveInBuffer.Reuse()
v NAudio.Wave.WaveIn.Callback(IntPtr waveInHandle, WaveMessage message, IntPtr userData, WaveHeader waveHeader, IntPtr reserved) v NAudio.Wave.WaveInBuffer.Reuse()
v NAudio.Wave.WaveIn.Callback(IntPtr waveInHandle, WaveMessage message, IntPtr userData, WaveHeader waveHeader, IntPtr reserved)
My simplified WaveIn initialization looks like:
micRecording = new WaveIn { WaveFormat = new WaveFormat(8000, 1) };
micRecording.DataAvailable += WaveSource_DataAvailable;
micRecording.RecordingStopped += WaveSource_RecordingStopped;
micRecording.StartRecording();
Note that the exception is not thrown when the recording was not started previously in past.
Sometimes the StartRecording will pass correctly, but recording will stop immediately with similar exception:
NAudio.MmException: NoDriver calling waveInAddBuffer
v NAudio.Wave.WaveInBuffer.Reuse()
v NAudio.Wave.WaveIn.Callback(IntPtr waveInHandle, WaveMessage message, IntPtr userData, WaveHeader waveHeader, IntPtr reserved) v NAudio.Wave.WaveInBuffer.Reuse()
v NAudio.Wave.WaveIn.Callback(IntPtr waveInHandle, WaveMessage message, IntPtr userData, WaveHeader waveHeader, IntPtr reserved)
The only walkaround I found is to call StartRecording again when MmException is thrown - the next try will be ok in most cases but I cannot use this walkaround when recording starts correctly but then stops on exception immediately.
WasapiCapture does not have this bug but needs some extra resamling in my case so I would prefer the WaveIn.
When I disable and re-enable microphone on system level the next one calling of WaveIn.StartRecording ends up with MmException: NoDriver calling waveInPrepareHeader.
My simplified WaveIn initialization looks like:
Note that the exception is not thrown when the recording was not started previously in past.
Sometimes the StartRecording will pass correctly, but recording will stop immediately with similar exception:
The only walkaround I found is to call StartRecording again when MmException is thrown - the next try will be ok in most cases but I cannot use this walkaround when recording starts correctly but then stops on exception immediately.
WasapiCapture does not have this bug but needs some extra resamling in my case so I would prefer the WaveIn.