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


Mar 28, 2012 at 8:41 PM

The Init function of the IWavePlayer does not seem to work well when used inside threads.

When it encounters a badwaveformat it destroys the thread. This still seems not to affect to main program thread, only additional threads created.

To handle this then you need another thread to check for the first one and create it again if Init has destroyed it. I know not, very elegant but a dirty hack.

Somehow the Init function seems a little bit busy cleaning things up :-)

Please answer if more clarification is needed or if you know what is going on.

Mar 28, 2012 at 9:54 PM

This is probably the solution ?

Mar 29, 2012 at 1:38 PM

Nope, still a problem.

Mar 29, 2012 at 1:40 PM

IWavePlayer is an interface. What implementation are you using? Also, it runs on whatever thread you call it from. What is your application written in - WinForms, WPF, something else?

Mar 29, 2012 at 2:41 PM

This is done in WinForms.

IWavePlayer wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

This is not a problem any more since I am now using AudioFileReader and returning WaveStream:

WaveStream readerStream = new AudioFileReader(argFileName);



The problem now is when recording and stopping the recording. Something happens in here that destroys the thread:

                        //Stop recording.
                        if (waveRecorder != null)

                            mediaState = MediaState.Stopped;

                            if (waveFileWriter != null)
                                waveFileWriter = null;

                            waveRecorder = null;

Is it right to call


Mar 29, 2012 at 2:52 PM

I strongly recommend against using Function callback. It has been the source of endless problems. Just go with the default windowed callbacks and you will be fine. If you must have another thread, use the new WaveOutEvent class