public void Write(AudioEvent anEvent)
{
if (null == anEvent ||
anEvent.DataBuffer == null ||
anEvent.DataLength < 1)
throw new ArgumentNullException("WaveSpeaker::Write(anEvent)");
try
{
// Get an available buffer
WAVEHDR aHeader = fAvailableBuffers.Dequeue();
// Prepare the header
UnprepareHeader(aHeader);
PrepareHeader(aHeader);
// copy the data to the buffer
Marshal.Copy(anEvent.DataBuffer, 0, aHeader.lpData, anEvent.DataBuffer.Length);
// Write it out to the device
Write(aHeader);
}
catch (Exception e)
{
Console.WriteLine("WaveSpeaker::Write - {0}", e.Message);
}
}