Increased music stability
This commit is contained in:
		@@ -92,8 +92,6 @@ namespace NadekoBot.Modules.Music.Classes
 | 
				
			|||||||
            }).ConfigureAwait(false);
 | 
					            }).ConfigureAwait(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var t = new Thread(new ThreadStart(async () =>
 | 
					            var t = new Thread(new ThreadStart(async () =>
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                try
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                while (!Destroyed)
 | 
					                while (!Destroyed)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@@ -101,6 +99,8 @@ namespace NadekoBot.Modules.Music.Classes
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if (audioClient?.ConnectionState != ConnectionState.Connected)
 | 
					                        if (audioClient?.ConnectionState != ConnectionState.Connected)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (audioClient != null)
 | 
				
			||||||
 | 
					                                try { await audioClient.DisconnectAsync().ConfigureAwait(false); } catch { }
 | 
				
			||||||
                            audioClient = await PlaybackVoiceChannel.ConnectAsync().ConfigureAwait(false);
 | 
					                            audioClient = await PlaybackVoiceChannel.ConnectAsync().ConfigureAwait(false);
 | 
				
			||||||
                            continue;
 | 
					                            continue;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
@@ -125,6 +125,11 @@ namespace NadekoBot.Modules.Music.Classes
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    catch (OperationCanceledException) { }
 | 
					                    catch (OperationCanceledException) { }
 | 
				
			||||||
 | 
					                    catch (Exception ex)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Console.WriteLine("Music thread almost crashed.");
 | 
				
			||||||
 | 
					                        Console.WriteLine(ex);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    finally
 | 
					                    finally
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if (!cancelToken.IsCancellationRequested)
 | 
					                        if (!cancelToken.IsCancellationRequested)
 | 
				
			||||||
@@ -137,11 +142,6 @@ namespace NadekoBot.Modules.Music.Classes
 | 
				
			|||||||
                        await Task.Delay(300).ConfigureAwait(false);
 | 
					                        await Task.Delay(300).ConfigureAwait(false);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch (Exception ex) {
 | 
					 | 
				
			||||||
                    Console.WriteLine("Music thread crashed.");
 | 
					 | 
				
			||||||
                    Console.WriteLine(ex);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }));
 | 
					            }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            t.Start();
 | 
					            t.Start();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user