From e30fd29085b59e6b891cc987841e970e3e93c8bd Mon Sep 17 00:00:00 2001 From: Joe4evr Date: Mon, 6 Nov 2017 04:06:28 +0100 Subject: [PATCH] Tweaks to audio docs (#867) * Tweaks to audio docs * Make it more obvious that -1 means infinity --- .../getting_started/samples/intro/structure.cs | 3 ++- docs/guides/voice/samples/audio_create_ffmpeg.cs | 9 ++++----- docs/guides/voice/samples/audio_ffmpeg.cs | 12 +++++++----- docs/guides/voice/samples/joining_audio.cs | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/guides/getting_started/samples/intro/structure.cs b/docs/guides/getting_started/samples/intro/structure.cs index c15e672ee..bdfc12b67 100644 --- a/docs/guides/getting_started/samples/intro/structure.cs +++ b/docs/guides/getting_started/samples/intro/structure.cs @@ -1,5 +1,6 @@ using System; using System.Reflection; +using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Discord; @@ -88,7 +89,7 @@ class Program await _client.StartAsync(); // Wait infinitely so your bot actually stays connected. - await Task.Delay(-1); + await Task.Delay(Timeout.Infinite); } private IServiceProvider _services; diff --git a/docs/guides/voice/samples/audio_create_ffmpeg.cs b/docs/guides/voice/samples/audio_create_ffmpeg.cs index e24af088b..dda560efe 100644 --- a/docs/guides/voice/samples/audio_create_ffmpeg.cs +++ b/docs/guides/voice/samples/audio_create_ffmpeg.cs @@ -1,11 +1,10 @@ private Process CreateStream(string path) { - var ffmpeg = new ProcessStartInfo + return Process.Start(new ProcessStartInfo { FileName = "ffmpeg", - Arguments = $"-i {path} -ac 2 -f s16le -ar 48000 pipe:1", + Arguments = $"-hide_banner -loglevel panic -i \"{path}\" -ac 2 -f s16le -ar 48000 pipe:1", UseShellExecute = false, RedirectStandardOutput = true, - }; - return Process.Start(ffmpeg); -} \ No newline at end of file + }); +} diff --git a/docs/guides/voice/samples/audio_ffmpeg.cs b/docs/guides/voice/samples/audio_ffmpeg.cs index b9430ac11..d36fbbc20 100644 --- a/docs/guides/voice/samples/audio_ffmpeg.cs +++ b/docs/guides/voice/samples/audio_ffmpeg.cs @@ -1,9 +1,11 @@ private async Task SendAsync(IAudioClient client, string path) { // Create FFmpeg using the previous example - var ffmpeg = CreateStream(path); - var output = ffmpeg.StandardOutput.BaseStream; - var discord = client.CreatePCMStream(AudioApplication.Mixed); - await output.CopyToAsync(discord); - await discord.FlushAsync(); + using (var ffmpeg = CreateStream(path)) + using (var output = ffmpeg.StandardOutput.BaseStream) + using (var discord = client.CreatePCMStream(AudioApplication.Mixed)) + { + try { await output.CopyToAsync(discord); } + finally { await discord.FlushAsync(); } + } } diff --git a/docs/guides/voice/samples/joining_audio.cs b/docs/guides/voice/samples/joining_audio.cs index 0cc36978a..4cec67540 100644 --- a/docs/guides/voice/samples/joining_audio.cs +++ b/docs/guides/voice/samples/joining_audio.cs @@ -7,4 +7,4 @@ public async Task JoinChannel(IVoiceChannel channel = null) // For the next step with transmitting audio, you would want to pass this Audio Client in to a service. var audioClient = await channel.ConnectAsync(); -} \ No newline at end of file +}