This project has moved and is read-only. For the latest updates, please go here.

unhandled exception

May 26, 2012 at 3:47 PM

Hi Mark

further to my last message about my program using WASAPI, my program seems to crash at random, maybe once or twice a day and the following error appears in the event log:

Application: AVR Audio Switch Fix.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
   at System.IO.UnmanagedMemoryStream.Read(Byte[], Int32, Int32)
   at NAudio.Wave.WaveFileReader.Read(Byte[], Int32, Int32)
   at NAudio.Wave.SampleProviders.Mono16SampleChunkConverter.LoadNextChunk(NAudio.Wave.IWaveProvider, Int32)
   at NAudio.Wave.WaveChannel32.Read(Byte[], Int32, Int32)
   at NAudio.Wave.ResamplerDmoStream.Read(Byte[], Int32, Int32)
   at NAudio.Wave.WasapiOut.FillBuffer(NAudio.Wave.IWaveProvider, Int32)
   at NAudio.Wave.WasapiOut.PlayThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()


i'm using a non targeted "catch" command but it's not being caught, and even with a specific catch command for system.argumentexception it still crashes. Can you tell from this why it's crashing?



May 31, 2012 at 4:55 PM

what are you actually playing from - a file on the disk or some kind of memory buffer?

May 31, 2012 at 5:00 PM

i'm playing a wav file from my resources, wouldn't mind playing from a buffer instead since the wav is silent anyway but can't work out how to create a wave in memory. Saw some reference to nullwavestream or something in an naudio post on here but it doesn't seem to exist

i think i fixed the crash anyway - hasn't happened in days. Before i was resetting the stream.position to 0 if it got above 65000 because i thought a variable i was using to record the position might overflow, but it never seems to so i'm just letting it go on forever, so it might have been something to do with that.