Fix close order

Close open audio streams (or at least give opportunity to do so)
This commit is contained in:
Flamefire committed 2014-05-06 18:37:46 +02:00
1 parent bafc79af15
commit c07526e195
8 files changed
+53 -55

No files matched your search

+14 -11
View File
@@ -18,9 +18,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using VocaluxeLib;
using VocaluxeLib.Draw;
@@ -35,7 +32,6 @@ namespace Vocaluxe.Base
static class CCover
{
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
private static readonly Dictionary<string, CTexture> _Covers = new Dictionary<string, CTexture>();
private static readonly List<SCoverTheme> _CoverThemes = new List<SCoverTheme>();
@@ -43,14 +39,16 @@ namespace Vocaluxe.Base
public static void Init()
{
_Settings.Indent = true;
_Settings.Encoding = Encoding.UTF8;
_Settings.ConformanceLevel = ConformanceLevel.Document;
_LoadCoverThemes();
_LoadCover(CConfig.CoverTheme);
}
public static void Close()
{
_UnloadCovers();
_CoverThemes.Clear();
}
/// <summary>
/// Returns an array of CoverThemes-Names
/// </summary>
@@ -106,18 +104,23 @@ namespace Vocaluxe.Base
/// <summary>
/// Reloads cover to use a new cover-theme
/// </summary>
public static void ReloadCover()
public static void ReloadCovers()
{
_UnloadCovers();
_LoadCover(CConfig.CoverTheme);
}
private static void _UnloadCovers()
{
lock (_Covers)
{
foreach (string key in _Covers.Keys.ToList())
foreach (string key in _Covers.Keys)
{
CTexture texture = _Covers[key];
CDraw.RemoveTexture(ref texture);
}
_Covers.Clear();
}
_LoadCover(CConfig.CoverTheme);
}
/// <summary>
+1 -1
View File
@@ -28,7 +28,7 @@ namespace Vocaluxe.Base
{
private static IDraw _Draw;
public static bool InitDraw()
public static bool Init()
{
if (_Draw != null)
return false;
+7
View File
@@ -106,6 +106,13 @@ namespace Vocaluxe.Base
CLog.StopBenchmark("Load Theme");
}
public static void Close()
{
if (_CurrentPopupScreen != EPopupScreens.NoPopup)
_PopupScreens[(int)_CurrentPopupScreen].OnClose();
_Screens[(int)_CurrentScreen].OnClose();
}
public static void LoadTheme()
{
_Cursor.LoadTextures();
-6
View File
@@ -19,8 +19,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using VocaluxeLib;
namespace Vocaluxe.Base
@@ -42,7 +40,6 @@ namespace Vocaluxe.Base
static class CLanguage
{
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
private static List<SLanguage> _Languages;
private static int _CurrentLanguage;
private static int _FallbackLanguage;
@@ -75,9 +72,6 @@ namespace Vocaluxe.Base
public static void Init()
{
_Languages = new List<SLanguage>();
_Settings.Indent = true;
_Settings.Encoding = Encoding.UTF8;
_Settings.ConformanceLevel = ConformanceLevel.Document;
var files = new List<string>();
files.AddRange(CHelper.ListFiles(CSettings.FolderLanguages, "*.xml", true, true));
-7
View File
@@ -19,7 +19,6 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using VocaluxeLib;
using VocaluxeLib.Menu;
@@ -28,8 +27,6 @@ namespace Vocaluxe.Base.Fonts
{
static class CFonts
{
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
private static readonly List<SFont> _Fonts = new List<SFont>();
private static int _CurrentFont;
private static float _Height = 1f;
@@ -58,10 +55,6 @@ namespace Vocaluxe.Base.Fonts
public static void Init()
{
_Settings.Indent = true;
_Settings.Encoding = Encoding.UTF8;
_Settings.ConformanceLevel = ConformanceLevel.Document;
_CurrentFont = 0;
PartyModeID = -1;
_BuildFonts();
+26 -24
View File
@@ -107,26 +107,17 @@ namespace Vocaluxe
// Create folders
CSettings.CreateFolders();
Application.DoEvents();
_SplashScreen = new CSplashScreen();
Application.DoEvents();
// Init Draw
CLog.StartBenchmark("Init Draw");
if (!CDraw.InitDraw())
if (!CDraw.Init())
throw new CLoadingException("drawing");
CLog.StopBenchmark("Init Draw");
Application.DoEvents();
// Init Database
CLog.StartBenchmark("Init Database");
if (!CDataBase.Init())
throw new CLoadingException("database");
CLog.StopBenchmark("Init Database");
Application.DoEvents();
// Init Playback
CLog.StartBenchmark("Init Playback");
if (!CSound.Init())
@@ -143,6 +134,22 @@ namespace Vocaluxe
Application.DoEvents();
// Init VideoDecoder
CLog.StartBenchmark("Init Videodecoder");
if (!CVideo.Init())
throw new CLoadingException("video");
CLog.StopBenchmark("Init Videodecoder");
Application.DoEvents();
// Init Database
CLog.StartBenchmark("Init Database");
if (!CDataBase.Init())
throw new CLoadingException("database");
CLog.StopBenchmark("Init Database");
Application.DoEvents();
//Init Webcam
CLog.StartBenchmark("Init Webcam");
if (!CWebcam.Init())
@@ -172,14 +179,6 @@ namespace Vocaluxe
Application.DoEvents();
// Init VideoDecoder
CLog.StartBenchmark("Init Videodecoder");
if (!CVideo.Init())
throw new CLoadingException("video");
CLog.StopBenchmark("Init Videodecoder");
Application.DoEvents();
// Load Cover
CLog.StartBenchmark("Init Cover");
CCover.Init();
@@ -257,19 +256,22 @@ namespace Vocaluxe
private static void _CloseProgram()
{
// Unloading
// Unloading in reverse order
try
{
CVocaluxeServer.Close();
CController.Close();
CVocaluxeServer.Close();
CGraphics.Close();
CCover.Close();
CBackgroundMusic.Close();
CWebcam.Close();
CDataBase.Close();
CVideo.Close();
CRecord.Close();
CSound.Close();
CVideo.Close();
CDraw.Unload();
CDataBase.Close();
CWebcam.Close();
GC.Collect(); // Do a GC run here before we close logs to have finalizers run
CLog.CloseAll();
CLog.CloseAll(); // Do this last, so we get all log entries!
}
catch (Exception) {}
Environment.Exit(Environment.ExitCode);
+1 -1
View File
@@ -179,7 +179,7 @@ namespace Vocaluxe.Screens
CConfig.SaveConfig();
if (_OldCoverTheme != _SelectSlides[_SelectSlideCover].Selection)
CCover.ReloadCover();
CCover.ReloadCovers();
if (_OldTheme != _SelectSlides[_SelectSlideTheme].Selection)
{
@@ -67,11 +67,11 @@ namespace VocaluxeLib.Menu.SongMenu
{
set
{
_PlaySong(value);
_PreviewIdInternal = value;
if (value == base._PreviewId)
return;
base._PreviewId = value;
_UpdatePreview();
}
get { return _PreviewIdInternal; }
}
public override int GetActualSelection()
@@ -373,8 +373,7 @@ namespace VocaluxeLib.Menu.SongMenu
if (!keyEvent.Handled)
{
_ActualSelection = _Locked;
if (_PreviewId != _Locked)
_PreviewId = _Locked;
_PreviewId = _Locked;
for (int i = 0; i < _Tiles.Count; i++)
_Tiles[i].Selected = _Locked == i + _Offset;