From 16f4d790deef7ec42b988187c104a3c6ca43facf Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Sun, 20 Dec 2015 17:36:22 +0100 Subject: [PATCH 1/6] get SongInfo in parallel --- Vocaluxe/Base/Server/CVocaluxeServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index 138df11f..42e1e63a 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -628,7 +628,7 @@ namespace Vocaluxe.Base.Server { List songs = CSongs.Songs; return (from s in songs - select _GetSongInfo(s, false)).ToArray(); + select _GetSongInfo(s, false)).AsParallel().ToArray(); } public static string GetMp3Path(int songId) From 871a7227fc448fd288a6365b9ef2cae6f61af102 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Sun, 20 Dec 2015 17:42:30 +0100 Subject: [PATCH 2/6] Webserver: GetAllSongs() uses now a cache --- Vocaluxe/Base/Server/CVocaluxeServer.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index 42e1e63a..6bce25f9 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -624,11 +624,18 @@ namespace Vocaluxe.Base.Server return _GetSongInfo(song, true); } + + private static SSongInfo[] songInfoCache = null; public static SSongInfo[] GetAllSongs() { - List songs = CSongs.Songs; - return (from s in songs + if (songInfoCache == null) + { + List songs = CSongs.Songs; + songInfoCache = (from s in songs select _GetSongInfo(s, false)).AsParallel().ToArray(); + } + + return songInfoCache; } public static string GetMp3Path(int songId) From df311b2916d3aba02d0749cc8cdfbc4811de50c5 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Sun, 20 Dec 2015 17:58:58 +0100 Subject: [PATCH 3/6] Webserver: Added a threshold to the config which decides at how many song we stop sending covers on get-all-songs requests. --- Vocaluxe/Base/CConfig.cs | 3 +++ Vocaluxe/Base/Server/CVocaluxeServer.cs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 6409815a..ea133582 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -163,6 +163,7 @@ namespace Vocaluxe.Base [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn ServerActive; [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn ServerEncryption; [DefaultValue(3000)] public int ServerPort; + [DefaultValue(70)] public int SongCountCoverThreshold; } #pragma warning restore 649 // ReSharper restore UnassignedField.Global @@ -495,6 +496,8 @@ namespace Vocaluxe.Base return "Server Encryption On/Off: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); case "ServerPort": return "Server Port (default: 3000) [1..65535]"; + case "SongCountCoverThreshold": + return "Threshold of songs for that covers will not longer be included in get-all-songs-requests (e.g. song list) (default: 70) [-1..65535] -1 => always deliver covers"; case "Stretch": return "Stretch view to full window size: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); default: diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index 6bce25f9..20e0cf20 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -628,11 +628,13 @@ namespace Vocaluxe.Base.Server private static SSongInfo[] songInfoCache = null; public static SSongInfo[] GetAllSongs() { + bool sendCovers = CConfig.Config.Server.SongCountCoverThreshold == -1 || CConfig.Config.Server.SongCountCoverThreshold > CSongs.Songs.Count; + if (songInfoCache == null) { List songs = CSongs.Songs; songInfoCache = (from s in songs - select _GetSongInfo(s, false)).AsParallel().ToArray(); + select _GetSongInfo(s, sendCovers)).AsParallel().ToArray(); } return songInfoCache; From ef3a7e0722cc1afd64035bb45bf304ca79af8c6a Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Sun, 20 Dec 2015 17:59:42 +0100 Subject: [PATCH 4/6] changed naming of a variable to be consistent to the naming rules --- Vocaluxe/Base/Server/CVocaluxeServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index 20e0cf20..7eeb2526 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -625,19 +625,19 @@ namespace Vocaluxe.Base.Server } - private static SSongInfo[] songInfoCache = null; + private static SSongInfo[] _SongInfoCache = null; public static SSongInfo[] GetAllSongs() { bool sendCovers = CConfig.Config.Server.SongCountCoverThreshold == -1 || CConfig.Config.Server.SongCountCoverThreshold > CSongs.Songs.Count; - if (songInfoCache == null) + if (_SongInfoCache == null) { List songs = CSongs.Songs; - songInfoCache = (from s in songs + _SongInfoCache = (from s in songs select _GetSongInfo(s, sendCovers)).AsParallel().ToArray(); } - return songInfoCache; + return _SongInfoCache; } public static string GetMp3Path(int songId) From 8da297d1be577ece1a1158df0ce0f1888166db0e Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Sun, 20 Dec 2015 18:39:14 +0100 Subject: [PATCH 5/6] Added optional covers to SongList --- Vocaluxe/Website/js/main.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js index 39b38b49..ed8d3e5a 100644 --- a/Vocaluxe/Website/js/main.js +++ b/Vocaluxe/Website/js/main.js @@ -1143,9 +1143,26 @@ } for (var id in allSongsCache) { - $('
  • '/*+' '*/ + '

    ' + allSongsCache[id].Artist + '

    ' + allSongsCache[id].Title + '

  • ') + var coverString = ""; + var currentCoverId = ""; + + if (allSongsCache[id].Cover !== null) { + if (allSongsCache[id].Cover.base64Data !== "") { + coverString = ''; + } + else if (allSongsCache[id].Cover.imageId !== "") { + currentCoverId = "songListCoverId_" + id; + coverString = ''; + } + } + + $('
  • ' + coverString + '

    ' + allSongsCache[id].Artist + '

    ' + allSongsCache[id].Title + '

  • ') .appendTo('#selectSongList') .click(handleSelectSongLineClick); + + if (currentCoverId !== "") { + imageLoader.delayedImageLoad($("#" + currentCoverId)[0], allSongsCache[id].Cover.imageId, "img/noCover.png"); + } } $('#selectSongList').listview('refresh'); From 7ff0ef52d7124ace1cd91c9e356e0042ced599d5 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Sun, 20 Dec 2015 18:41:06 +0100 Subject: [PATCH 6/6] Deliver noCover if there is no cover and includeCover==true --- Vocaluxe/Base/Server/CVocaluxeServer.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index 7eeb2526..477713b6 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -667,7 +667,17 @@ namespace Vocaluxe.Base.Server result.IsDuet = song.IsDuet; result.SongId = song.ID; if (includeCover) - result.Cover = new CBase64Image(_CreateDelayedImage(song.Folder + "\\" + song.CoverFileName)); + { + if (song.CoverFileName == "") + { + result.Cover = new CBase64Image(_CreateDelayedImage("Website\\img\\noCover.png")); + } + else + { + result.Cover = new CBase64Image(_CreateDelayedImage(song.Folder + "\\" + song.CoverFileName)); + } + } + } return result; }