From 6e9d6a9b6ce9ad051bfb0bdf6d9db9af83992fd1 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sun, 18 Oct 2015 16:50:06 -0300 Subject: [PATCH] Don't crash on voice buffer clear --- src/Discord.Net/WebSockets/Voice/VoiceBuffer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net/WebSockets/Voice/VoiceBuffer.cs b/src/Discord.Net/WebSockets/Voice/VoiceBuffer.cs index 8f3dc9f53..b3f04281d 100644 --- a/src/Discord.Net/WebSockets/Voice/VoiceBuffer.cs +++ b/src/Discord.Net/WebSockets/Voice/VoiceBuffer.cs @@ -46,7 +46,11 @@ namespace Discord.WebSockets.Voice if (_readCursor == nextPosition) { _notOverflowEvent.Reset(); - _notOverflowEvent.Wait(cancelToken); + try + { + _notOverflowEvent.Wait(cancelToken); + } + catch (OperationCanceledException) { return; } } if (i == wholeFrames) @@ -100,7 +104,11 @@ namespace Discord.WebSockets.Voice _isClearing = true; for (int i = 0; i < _frameCount; i++) Buffer.BlockCopy(_blankFrame, 0, _buffer, i * _frameCount, i++); - _underflowEvent.Wait(cancelToken); + try + { + _underflowEvent.Wait(cancelToken); + } + catch (OperationCanceledException) { } _writeCursor = 0; _readCursor = 0; _isClearing = false;