Class OutputStream
表示输出音频流,用于包装一个 IAudioClient,在写入时向语音服务器发送语音数据。
public class OutputStream : AudioOutStream, IAsyncDisposable, IDisposable
- Inheritance
-
OutputStream
- Implements
- Inherited Members
Methods
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[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
buffer
byte[]The buffer to write data from.
offset
intThe zero-based byte offset in
buffer
from which to begin copying bytes to the stream.count
intThe maximum number of bytes to write.
cancellationToken
CancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
- Task
A task that represents the asynchronous write operation.
Exceptions
- ArgumentNullException
buffer
is null.- ArgumentOutOfRangeException
offset
orcount
is negative.- ArgumentException
The sum of
offset
andcount
is 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
该流不接收头部信息。