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
+52 -54

No files matched your search

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