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

Error :- MemoryAllocationError calling waveOutOpen while playing in a loop

Mar 31, 2012 at 11:21 AM

I have a waveOut that plays inside a while loop which receives data from a udp socket.
But unfortunately it trows an error after around 30 secs saying "MemoryAllocationError calling waveOutOpen"
I use the below lines of code to achieve this.

waveOutStream = new WaveOut(); while (IsAudioTransferActive) { receivedAudioData = audioUDPClient.Receive(ref senderEP); audioDataStream = new MemoryStream(receivedAudioData); receivedRawAudioData = new RawSourceWaveStream(audioDataStream, audioFormat); waveOutStream.Init(receivedRawAudioData); waveOutStream.Play(); }
Thanks in advance.

Apr 2, 2012 at 9:40 AM

you should be doing your waveOutStream Init and Play outside the loop, and use a BufferedWaveProvider to feed wave out. Inside the loop, you shuold put the data received into the BufferedWaveProvider.

Also, from your code, it looks like you are on a background thread so I recommend using WaveOutEvent instead of WaveOut for playback.