protected override async Task Cleanup()
{
var sendThread = _sendTask;
if (sendThread != null)
{
try { await sendThread.ConfigureAwait(false); }
catch (Exception) { } //Ignore any errors during cleanup
}
_sendTask = null;
var receiveThread = _receiveTask;
if (receiveThread != null)
{
try { await receiveThread.ConfigureAwait(false); }
catch (Exception) { } //Ignore any errors during cleanup
}
_receiveTask = null;
OpusDecoder decoder;
foreach (var pair in _decoders)
{
if (_decoders.TryRemove(pair.Key, out decoder))
decoder.Dispose();
}
ClearPCMFrames();
_udp = null;
await base.Cleanup().ConfigureAwait(false);
}