Bugfixes for CDataBase/COpenGL
Changed dynamic song loading to not use a thread as it was not threadsafe before
This commit is contained in:
1 parent
bd3f51b17e
commit
d2f8af880e
4 files changed
+45
-42
No files matched your search
@@ -1011,8 +1011,6 @@ namespace Vocaluxe.Base
|
||||
#region Cover
|
||||
public static bool GetCover(string CoverPath, ref STexture tex, int MaxSize)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (!File.Exists(CoverPath))
|
||||
{
|
||||
CLog.LogError("Can't find File: " + CoverPath);
|
||||
@@ -1048,10 +1046,11 @@ namespace Vocaluxe.Base
|
||||
|
||||
if (reader.HasRows)
|
||||
{
|
||||
result = true;
|
||||
reader.Read();
|
||||
byte[] data = GetBytes(reader);
|
||||
reader.Dispose();
|
||||
tex = CDraw.QuequeTexture(w, h, ref data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1120,19 +1119,17 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
reader.Read();
|
||||
int id = reader.GetInt32(0);
|
||||
reader.Dispose();
|
||||
command.CommandText = "INSERT INTO CoverData (CoverID, Data) VALUES (@id, @data)";
|
||||
command.Parameters.Add("@id", DbType.Int32).Value = id;
|
||||
command.Parameters.Add("@data", System.Data.DbType.Binary, 20).Value = data;
|
||||
command.ExecuteReader();
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (reader != null)
|
||||
reader.Dispose();
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void CommitCovers()
|
||||
@@ -1284,14 +1281,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
command.CommandText = "SELECT Data FROM ImageData WHERE ImageID = @id";
|
||||
command.Parameters.Add("@id",DbType.Int32).Value=id;
|
||||
try
|
||||
{
|
||||
reader = command.ExecuteReader();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
reader = command.ExecuteReader();
|
||||
|
||||
if (reader.HasRows)
|
||||
{
|
||||
|
||||
@@ -324,7 +324,7 @@ namespace Vocaluxe.Base
|
||||
CInput.Update();
|
||||
|
||||
if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC && _CurrentScreen != EScreens.ScreenSing)
|
||||
CSongs.LoadCover();
|
||||
CSongs.LoadCover(30, 1);
|
||||
|
||||
if (CSettings.GameState != EGameState.EditTheme)
|
||||
{
|
||||
|
||||
+30
-24
@@ -43,7 +43,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
private static bool _SongsLoaded = false;
|
||||
private static bool _CoverLoaded = false;
|
||||
private static int _CoverLoadIndex = -1;
|
||||
private static int _CoverLoadIndex = 0;
|
||||
private static int _CatIndex = -1;
|
||||
private static bool _Init = false;
|
||||
private static List<CCategory> _Categories = new List<CCategory>();
|
||||
@@ -56,8 +56,6 @@ namespace Vocaluxe.Base
|
||||
private static EOffOn _IgnoreArticles = CConfig.IgnoreArticles;
|
||||
private static ESongSorting _SongSorting = CConfig.SongSorting;
|
||||
private static bool _ShowDuetSongs = true;
|
||||
|
||||
private static Thread _CoverLoaderThread = null;
|
||||
|
||||
public static string SearchFilter
|
||||
{
|
||||
@@ -180,10 +178,10 @@ namespace Vocaluxe.Base
|
||||
if (!SongsLoaded)
|
||||
return -1;
|
||||
|
||||
if (_Songs.Count > _CoverLoadIndex + 1)
|
||||
if (_CoverLoadIndex < _Songs.Count)
|
||||
{
|
||||
_CoverLoadIndex++;
|
||||
Song = _Songs[_CoverLoadIndex];
|
||||
_CoverLoadIndex++;
|
||||
return _CoverLoadIndex;
|
||||
}
|
||||
|
||||
@@ -191,7 +189,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
public static int NumSongsWithCoverLoaded
|
||||
{
|
||||
get { return _CoverLoadIndex + 1; }
|
||||
get { return _CoverLoadIndex; }
|
||||
}
|
||||
|
||||
public static void SetCoverSmall(int SongIndex, STexture Texture)
|
||||
@@ -200,11 +198,7 @@ namespace Vocaluxe.Base
|
||||
return;
|
||||
|
||||
if (SongIndex < _Songs.Count)
|
||||
{
|
||||
_Songs[SongIndex].CoverTextureSmall = Texture;
|
||||
if (SongIndex == _Songs.Count - 1)
|
||||
_CoverLoaded = true;
|
||||
}
|
||||
|
||||
}
|
||||
public static void SetCoverBig(int SongIndex, STexture Texture)
|
||||
@@ -213,11 +207,7 @@ namespace Vocaluxe.Base
|
||||
return;
|
||||
|
||||
if (SongIndex < _Songs.Count)
|
||||
{
|
||||
_Songs[SongIndex].CoverTextureBig = Texture;
|
||||
if (SongIndex == _Songs.Count - 1)
|
||||
_CoverLoaded = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -752,32 +742,48 @@ namespace Vocaluxe.Base
|
||||
if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART)
|
||||
{
|
||||
CLog.StartBenchmark(2, "Load Covers/Notes");
|
||||
_LoadCover();
|
||||
_LoadCoverAndNotes();
|
||||
CLog.StopBenchmark(2, "Load Covers/Notes");
|
||||
}
|
||||
CLog.StopBenchmark(1, "Load Songs ");
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
public static void LoadCover()
|
||||
public static void LoadCover(int WaitTime, int NumLoads)
|
||||
{
|
||||
if (CConfig.Renderer == ERenderer.TR_CONFIG_SOFTWARE)
|
||||
return;
|
||||
return; //should be removed as soon as the other renderer are ready for queque
|
||||
|
||||
if (!SongsLoaded || CoverLoaded)
|
||||
return;
|
||||
|
||||
if (_CoverLoaderThread == null)
|
||||
if (!_CoverLoadTimer.IsRunning)
|
||||
{
|
||||
_CoverLoaderThread = new Thread(new ThreadStart(_LoadCover));
|
||||
_CoverLoaderThread.Name = "CoverLoader";
|
||||
_CoverLoaderThread.Priority = ThreadPriority.BelowNormal;
|
||||
_CoverLoaderThread.IsBackground = true;
|
||||
_CoverLoaderThread.Start();
|
||||
_CoverLoadTimer.Reset();
|
||||
_CoverLoadTimer.Start();
|
||||
}
|
||||
|
||||
if (_CoverLoadTimer.ElapsedMilliseconds >= WaitTime)
|
||||
{
|
||||
for (int i = 0; i < NumLoads; i++)
|
||||
{
|
||||
CSong song = null;
|
||||
int n = GetNextSongWithoutCover(ref song);
|
||||
|
||||
if (n < 0)
|
||||
return;
|
||||
|
||||
song.LoadSmallCover();
|
||||
|
||||
if (n == NumAllSongs)
|
||||
CDataBase.CommitCovers();
|
||||
}
|
||||
_CoverLoadTimer.Reset();
|
||||
_CoverLoadTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private static void _LoadCover()
|
||||
private static void _LoadCoverAndNotes()
|
||||
{
|
||||
foreach(CSong song in _Songs)
|
||||
{
|
||||
|
||||
@@ -733,7 +733,14 @@ namespace Vocaluxe.Lib.Draw
|
||||
CLog.LogError("Error loading Texture: " + TexturePath);
|
||||
return new STexture(-1);
|
||||
}
|
||||
return AddTexture(bmp, TexturePath);
|
||||
try
|
||||
{
|
||||
return AddTexture(bmp, TexturePath);
|
||||
}
|
||||
finally
|
||||
{
|
||||
bmp.Dispose();
|
||||
}
|
||||
}
|
||||
CLog.LogError("Can't find File: " + TexturePath);
|
||||
return new STexture(-1);
|
||||
|
||||
Reference in new issue
Block a user