possible deadlock fix
This commit is contained in:
		| @@ -26,16 +26,13 @@ namespace NadekoBot.Classes.Music { | |||||||
|         public MusicControls() { |         public MusicControls() { | ||||||
|             Task.Run(async () => { |             Task.Run(async () => { | ||||||
|                 while (!Stopped) { |                 while (!Stopped) { | ||||||
|                     lock (_voiceLock) { |                     if (CurrentSong == null) { | ||||||
|                         if (CurrentSong == null) { |                         if (SongQueue.Count > 0) | ||||||
|                             if (SongQueue.Count > 0) |                             await LoadNextSong(); | ||||||
|                                 LoadNextSong().Wait(); |  | ||||||
|  |  | ||||||
|                         } else if (CurrentSong.State == StreamState.Completed || NextSong) { |  | ||||||
|                             NextSong = false; |  | ||||||
|                             LoadNextSong().Wait(); |  | ||||||
|                         } |  | ||||||
|  |  | ||||||
|  |                     } else if (CurrentSong.State == StreamState.Completed || NextSong) { | ||||||
|  |                         NextSong = false; | ||||||
|  |                         await LoadNextSong(); | ||||||
|                     } |                     } | ||||||
|                     await Task.Delay(1000); |                     await Task.Delay(1000); | ||||||
|                 } |                 } | ||||||
| @@ -71,18 +68,16 @@ namespace NadekoBot.Classes.Music { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         internal void Stop() { |         internal void Stop() { | ||||||
|             lock (_voiceLock) { |             Stopped = true; | ||||||
|                 Stopped = true; |             foreach (var kvp in SongQueue) { | ||||||
|                 foreach (var kvp in SongQueue) { |                 if (kvp != null) | ||||||
|                     if (kvp != null) |                     kvp.Stop(); | ||||||
|                         kvp.Stop(); |  | ||||||
|                 } |  | ||||||
|                 SongQueue.Clear(); |  | ||||||
|                 CurrentSong?.Stop(); |  | ||||||
|                 CurrentSong = null; |  | ||||||
|                 VoiceClient?.Disconnect(); |  | ||||||
|                 VoiceClient = null; |  | ||||||
|             } |             } | ||||||
|  |             SongQueue.Clear(); | ||||||
|  |             CurrentSong?.Stop(); | ||||||
|  |             CurrentSong = null; | ||||||
|  |             VoiceClient?.Disconnect(); | ||||||
|  |             VoiceClient = null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         internal bool TogglePause() => IsPaused = !IsPaused; |         internal bool TogglePause() => IsPaused = !IsPaused; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user