Browse Source

Added AudioLock & Modified Throw

AudioLock << Copied to catch block to release before throwing an exception. Previously, this was known to lockup & prevent new audio clients from spawning.

Modified Throw << Now throws the caught exception. This previously wasn't producing a stacktrace.
pull/1072/head
ComputerMaster1st 7 years ago
parent
commit
850dc13faa
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 7
- 4
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -549,10 +549,13 @@ namespace Discord.WebSocket


await Discord.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false); await Discord.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false);
} }
catch (Exception)
catch (Exception e)
{ {
await DisconnectAudioInternalAsync().ConfigureAwait(false); await DisconnectAudioInternalAsync().ConfigureAwait(false);
throw;

// Since we're throwing an exception, we must release the audiolock to prevent future lockups/hanging.
_audioLock.Release();
throw e;
} }
finally finally
{ {
@@ -566,10 +569,10 @@ namespace Discord.WebSocket
throw new TimeoutException(); throw new TimeoutException();
return await promise.Task.ConfigureAwait(false); return await promise.Task.ConfigureAwait(false);
} }
catch (Exception)
catch (Exception e)
{ {
await DisconnectAudioAsync().ConfigureAwait(false); await DisconnectAudioAsync().ConfigureAwait(false);
throw;
throw e;
} }
} }




Loading…
Cancel
Save