diff options
| author | Michael <[email protected]> | 2017-05-13 10:22:51 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-13 10:22:51 -0400 |
| commit | c0f0e99f9d2a092209e710107c1f061fc8a2eaca (patch) | |
| tree | 98169cbdfdc13966719671178ba982dbad5808e3 /ShiftOS.WinForms/AudioManager.cs | |
| parent | 94e1603b8574b45b809d3c66b6b90e7734a99d1e (diff) | |
| download | shiftos_thereturn-c0f0e99f9d2a092209e710107c1f061fc8a2eaca.tar.gz shiftos_thereturn-c0f0e99f9d2a092209e710107c1f061fc8a2eaca.tar.bz2 shiftos_thereturn-c0f0e99f9d2a092209e710107c1f061fc8a2eaca.zip | |
Dithering, audio volume, and fix shutdown bug
Diffstat (limited to 'ShiftOS.WinForms/AudioManager.cs')
| -rw-r--r-- | ShiftOS.WinForms/AudioManager.cs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/ShiftOS.WinForms/AudioManager.cs b/ShiftOS.WinForms/AudioManager.cs index eb0e798..ec12614 100644 --- a/ShiftOS.WinForms/AudioManager.cs +++ b/ShiftOS.WinForms/AudioManager.cs @@ -74,7 +74,19 @@ namespace ShiftOS.WinForms MemoryStream str = null; NAudio.Wave.Mp3FileReader mp3 = null; NAudio.Wave.WaveOut o = null; - while (!Engine.SaveSystem.ShuttingDown) + bool shuttingDown = false; + + Engine.AppearanceManager.OnExit += () => + { + shuttingDown = true; + o?.Stop(); + o?.Dispose(); + mp3?.Close(); + mp3?.Dispose(); + str?.Close(); + str?.Dispose(); + }; + while (shuttingDown == false) { str = new MemoryStream(GetRandomSong()); mp3 = new NAudio.Wave.Mp3FileReader(str); @@ -87,14 +99,15 @@ namespace ShiftOS.WinForms c = true; }; while (!c) + { + try + { + o.Volume = (float)Engine.SaveSystem.CurrentSave.MusicVolume / 100; + } + catch { } Thread.Sleep(10); - str.Dispose(); - o.Dispose(); - mp3.Dispose(); + } } - str?.Dispose(); - o?.Dispose(); - mp3?.Dispose(); }); athread.IsBackground = true; athread.Start(); |
