public class StreamingSourceVoice : XAudio2SourceVoice
Extends the the XAudio2SourceVoice to enable real-time audio streaming.
Stopped
Occurs when the playback stops and no more data is available.
public Stopped
Remarks
This event occurs whenever the StreamEnd event occurs.
StreamingSourceVoice(IntPtr ptr, VoiceCallback voiceCallback, IWaveSource waveSource, Int32 bufferSize)
Initializes a new instance of the StreamingSourceVoice class.
public void StreamingSourceVoice(IntPtr ptr, VoiceCallback voiceCallback, IWaveSource waveSource, Int32 bufferSize)
Parameters
ptr
IntPtrPointer to a XAudio2SourceVoice object.
voiceCallback
VoiceCallbackVoiceCallback instance which receives notifications from the XAudio2SourceVoice which got passed as a pointer (see the ptr argument).
waveSource
IWaveSourceIWaveSource which provides the audio data to stream.
bufferSize
Int32Buffersize of the internal used buffers in milliseconds. Values in the range from 70ms to 200ms are recommended.
Remarks
It is recommended to use the Create method instead of the this constructor.
Create(XAudio2 xaudio2, IWaveSource waveSource, Int32 bufferSize)
Creates an instance of the StreamingSourceVoice class.
public static StreamingSourceVoice Create(XAudio2 xaudio2, IWaveSource waveSource, Int32 bufferSize)
Parameters
xaudio2
XAudio2Instance of the XAudio2 class.
waveSource
IWaveSourceIWaveSource which provides the audio data to stream.
bufferSize
Int32Buffersize of the internal used buffers in milliseconds. Values in the range from 70ms to 200ms are recommended.
Returns
Configured StreamingSourceVoice instance.
Dispose(Boolean disposing)
Stops and disposes the XAudio2SourceVoice, closes the internal used waithandle and frees the allocated memory of all used buffers.
Refill()
Notifies the StreamingSourceVoice class that new data got requested. If there are any buffers which are currently not queued and the underlying IWaveSource holds any more data, this data refills the internal used buffers and provides audio data to play.