I am working on a recording program using win32 API and waveIn. Everything works fine so far, BUT the waveIn part crashes when I unplug the microphone cable. Seems that my laptop automatically switches from the jack input to the built in microphone, disabling the jack input. Plugging in the jack again doesn't help.
The only solution I found was to restart the program, the functions waveInStop() and/or waveInClose() don't work after plugging/unplugging the cable.
Does anybody have an idea how to solve this problem?
It "crashes", as in it brings down your entire program? That seems unlikely.
All waveIn functions return error codes. It's more likely that your wavein object is getting in a bad state when the plug is removed -- and then the following calls with your handle are failing.
Are you checking the return values to make sure the calls succeed?