Cleaned up audio code
This commit is contained in:
23
src/Discord.Net.WebSocket/Audio/Streams/OutputStream.cs
Normal file
23
src/Discord.Net.WebSocket/Audio/Streams/OutputStream.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.Audio.Streams
|
||||
{
|
||||
///<summary> Wraps an IAudioClient, sending voice data on write. </summary>
|
||||
public class OutputStream : AudioOutStream
|
||||
{
|
||||
private readonly DiscordVoiceAPIClient _client;
|
||||
public OutputStream(IAudioClient client)
|
||||
: this((client as AudioClient).ApiClient) { }
|
||||
internal OutputStream(DiscordVoiceAPIClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancelToken)
|
||||
{
|
||||
cancelToken.ThrowIfCancellationRequested();
|
||||
await _client.SendAsync(buffer, offset, count).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user