问题
Edit
After modifying the NAudio source code and a little debugging, I found that the mixerSetControlDetails
function, which is called when I set the Value
property, returns MMSYSERR_ERROR
.
Is there a way to get further information about why mixerSetControlDetails
failed?
I'm also open to other ways to accomplish same thing on C#.
Original
I have some code that computes energy in voice and sets the microphone boost level according to this computed value using NAudio. I have no problem reading audio samples but when I try to set microphone boost, the program gets stuck.
I have checked the issue on Windows 7, 8, and 8.1. The problem occurs only on Windows 8.1. Interestingly when I run the program on a virtual machine with Windows 8.1 it works as expected. Can this be a permission problem?
Here is the code for setting the boost value
foreach (MixerControl mixerControl in MixerLine.Controls)
{
if (mixerControl.ControlType == MixerControlType.Volume)
{
UnsignedMixerControl volumeControl = (UnsignedMixerControl)mixerControl;
volumeControl.Value = (uint) value;
}
}
Where MixerLine is created beforehand with this code.
MixerLine = new MixerLine((IntPtr) deviceID, 0, MixerFlags.WaveIn);
回答1:
It seems the mixerSetControlDetails
function returns MMSYSERR_ERROR
randomly (at least I couldn't find a pattern). Actually it does set the new value, just ignore the exception, or if it does not set try setting the value again. The stuck behavior was about my program, irrelevant to this error.
来源:https://stackoverflow.com/questions/29622213/windows-8-1-wpf-application-mixersetcontroldetails-returns-mmsyserr-error