Class BufferedWriteStream
Wraps another stream with a timed buffer.
public class BufferedWriteStream : AudioOutStream, IAsyncDisposable, IDisposable
- Inheritance
-
BufferedWriteStream
- Implements
- Inherited Members
Constructors
BufferedWriteStream(AudioStream, IAudioClient, int, CancellationToken, int)
public BufferedWriteStream(AudioStream next, IAudioClient client, int bufferMillis, CancellationToken cancelToken, int maxFrameSize = 1500)
Parameters
nextAudioStreamclientIAudioClientbufferMillisintcancelTokenCancellationTokenmaxFrameSizeint
Methods
ClearAsync(CancellationToken)
public override Task ClearAsync(CancellationToken cancelToken)
Parameters
cancelTokenCancellationToken
Returns
Dispose(bool)
Releases the unmanaged resources used by the Stream and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
FlushAsync(CancellationToken)
Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.
public override Task FlushAsync(CancellationToken cancelToken)
Parameters
cancelTokenCancellationToken
Returns
- Task
A task that represents the asynchronous flush operation.
Exceptions
- ObjectDisposedException
The stream has been disposed.
- OperationCanceledException
The cancellation token was canceled. This exception is stored into the returned task.
WriteAsync(byte[], int, int, CancellationToken)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.
public override Task WriteAsync(byte[] data, int offset, int count, CancellationToken cancelToken)
Parameters
databyte[]offsetintThe zero-based byte offset in
bufferfrom which to begin copying bytes to the stream.countintThe maximum number of bytes to write.
cancelTokenCancellationToken
Returns
- Task
A task that represents the asynchronous write operation.
Exceptions
- ArgumentNullException
bufferis null.- ArgumentOutOfRangeException
offsetorcountis negative.- ArgumentException
The sum of
offsetandcountis larger than the buffer length.- NotSupportedException
The stream does not support writing.
- ObjectDisposedException
The stream has been disposed.
- InvalidOperationException
The stream is currently in use by a previous write operation.
- OperationCanceledException
The cancellation token was canceled. This exception is stored into the returned task.
WriteHeader(ushort, uint, bool)
public override void WriteHeader(ushort seq, uint timestamp, bool missed)
Parameters
Exceptions
- InvalidOperationException
This stream does not accept headers.