Jan 4, 2013 at 11:26 AM
Edited Jan 4, 2013 at 3:11 PM
I have created Audio player which supports GUI as well as thread environment. It works fine if we are playing audio on GUI thread but if there are so many background threads which are playing audio file then within 1 hour audio player getting crashed
with above exception.
to support threading i am using WaveOutEvent.
Also internally for each play i am creating new device to play loaded audio.
All operation like create device, stop, play audio, reset duration am doing on single thread using AutoResetEvent.
Also if we want to play audio for 30 seconds then i am playing same audio for 30 second but for each replay i am creating new device and loading same file again.
for play and replay purpose i am using same code please check following
private bool PlayAudioFile()
if (_wavePlayer == null || _fileStream == null || _wavePlayer.PlaybackState == PlaybackState.Playing)
_fileStream.Position = 0;
_dontFireEvent = false;
here EnsureDeviceCreated creating new WaveOutEvent with 200 latency.
Exception coming at following line in WaveOutBuffer's constructor.
MmException.Try(WaveInterop.waveOutPrepareHeader(hWaveOut, header, Marshal.SizeOf(header)), "waveOutPrepareHeader");
Please help me to sort out above issue...
Thanks in Advanced..