Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: Stop or Dispose methods hang if USB device undocked while playing wav file

$
0
0

I got my solution to work. Changed from the WaveOut class to the WaveOutEvent class, in the WaveOutEvent class the call to the WinMM.Dll waveOutWrite method would throw and exception instead of deadlocking. I ammended the code for WaveOutEvent to catch the MMException being thrown, this catch is in the PlaybackThread method and the handler has the following

catch(MmException ex)

{

buffer = null;

playbackState = PlaybackState.Stopped;

System.Diagnostics.Debug.WrtieLine(ex); // so a debugger can view this is happend and to be able to log using trace listeners.

}

 

If I did not catch the exception there I would get an unhandled error which is not caught by the application general exception error and my appliation would crash and be unloaded from memory.

 

Mark


Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>