From 6e8c8ec5107f9d9fa51db30142b4c45e16a9bf01 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Fri, 24 Feb 2012 15:26:10 +0100 Subject: [PATCH 1/5] made critical acinerella methods private --- Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs index 06a8597b..6221f6dd 100644 --- a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs +++ b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs @@ -180,7 +180,7 @@ namespace Vocaluxe.Lib.Video.Acinerella // Initializes an Acinerella instance. //function ac_init(): PAc_instance; cdecl; external ac_dll; [DllImport(AcDll, EntryPoint = "ac_init", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern IntPtr _ac_init(); + private static extern IntPtr _ac_init(); public static IntPtr ac_init() { @@ -193,7 +193,7 @@ namespace Vocaluxe.Lib.Video.Acinerella // Frees an Acinerella instance. //procedure ac_free(inst: PAc_instance); cdecl; external ac_dll; [DllImport(AcDll, EntryPoint = "ac_free", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern void _ac_free(IntPtr PAc_instance); + private static extern void _ac_free(IntPtr PAc_instance); public static void ac_free(IntPtr PAc_instance) { @@ -221,7 +221,7 @@ namespace Vocaluxe.Lib.Video.Acinerella proberesult: PAc_proberesult): integer; cdecl; external ac_dll; */ [DllImport(AcDll, EntryPoint = "ac_open", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern Int32 _ac_open( + private static extern Int32 _ac_open( IntPtr PAc_instance, IntPtr sender, TAc_openclose_callback open_proc, @@ -250,7 +250,7 @@ namespace Vocaluxe.Lib.Video.Acinerella // Closes an opened media file. //procedure ac_close(inst: PAc_instance);cdecl; external ac_dll; [DllImport(AcDll, EntryPoint = "ac_close", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern void _ac_close(IntPtr PAc_instance); + private static extern void _ac_close(IntPtr PAc_instance); public static void ac_close(IntPtr PAc_instance) { @@ -264,7 +264,7 @@ namespace Vocaluxe.Lib.Video.Acinerella //procedure ac_get_stream_info( //inst: PAc_instance; nb: integer; pinfo: PAc_stream_info); cdecl; external ac_dll; [DllImport(AcDll, EntryPoint = "ac_get_stream_info", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern void _ac_get_stream_info( + private static extern void _ac_get_stream_info( IntPtr PAc_instance, Int32 nb, out TAc_stream_info Info @@ -300,7 +300,7 @@ namespace Vocaluxe.Lib.Video.Acinerella // could be found. //function ac_create_decoder(pacInstance: PAc_instance; nb: integer): PAc_decoder; cdecl; external ac_dll; [DllImport(AcDll, EntryPoint = "ac_create_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern IntPtr _ac_create_decoder(IntPtr PAc_instance, Int32 nb); + private static extern IntPtr _ac_create_decoder(IntPtr PAc_instance, Int32 nb); public static IntPtr ac_create_decoder(IntPtr PAc_instance, Int32 nb) { @@ -313,7 +313,7 @@ namespace Vocaluxe.Lib.Video.Acinerella // Frees an created decoder. //procedure ac_free_decoder(pDecoder: PAc_decoder); cdecl; external ac_dll; [DllImport(AcDll, EntryPoint = "ac_free_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern void _ac_free_decoder(IntPtr PAc_decoder); + private static extern void _ac_free_decoder(IntPtr PAc_decoder); public static void ac_free_decoder(IntPtr PAc_decoder) { @@ -327,7 +327,7 @@ namespace Vocaluxe.Lib.Video.Acinerella // "buffer" property of the decoder. //function ac_decode_package(pPackage: PAc_package; pDecoder: PAc_decoder): integer; cdecl; external ac_dll; [DllImport(AcDll, EntryPoint = "ac_decode_package", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern Int32 _ac_decode_package(IntPtr PAc_package, IntPtr PAc_decoder); + private static extern Int32 _ac_decode_package(IntPtr PAc_package, IntPtr PAc_decoder); public static Int32 ac_decode_package(IntPtr PAc_package, IntPtr PAc_decoder) { @@ -338,7 +338,7 @@ namespace Vocaluxe.Lib.Video.Acinerella } [DllImport(AcDll, EntryPoint = "ac_get_audio_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern Int32 _ac_get_audio_frame(IntPtr PAcInstance, IntPtr PAc_decoder); + private static extern Int32 _ac_get_audio_frame(IntPtr PAcInstance, IntPtr PAc_decoder); public static Int32 ac_get_audio_frame(IntPtr PAcInstance, IntPtr PAc_decoder) { @@ -349,7 +349,7 @@ namespace Vocaluxe.Lib.Video.Acinerella } [DllImport(AcDll, EntryPoint = "ac_get_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern Int32 _ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder); + private static extern Int32 _ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder); public static Int32 ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder) @@ -360,7 +360,7 @@ namespace Vocaluxe.Lib.Video.Acinerella } } [DllImport(AcDll, EntryPoint = "ac_skip_frames", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern Int32 _ac_skip_frames(IntPtr PAcInstance, IntPtr PAc_decoder, Int32 num); + private static extern Int32 _ac_skip_frames(IntPtr PAcInstance, IntPtr PAc_decoder, Int32 num); public static Int32 ac_skip_frames(IntPtr PAcInstance, IntPtr PAc_decoder, Int32 num) { @@ -376,7 +376,7 @@ namespace Vocaluxe.Lib.Video.Acinerella // The target_pos paremeter is in milliseconds. Returns 1 if the functions succeded.} //function ac_seek(pDecoder: PAc_decoder; dir: integer; target_pos: int64): integer; cdecl; external ac_dll; [DllImport(AcDll, EntryPoint = "ac_seek", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] - public static extern Int32 _ac_seek(IntPtr PAc_decoder, Int32 dir, Int64 target_pos); + private static extern Int32 _ac_seek(IntPtr PAc_decoder, Int32 dir, Int64 target_pos); public static Int32 ac_seek(IntPtr PAc_decoder, Int32 dir, Int64 target_pos) { From 00f96dc20f620795e522981198cd79257e629771 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Fri, 24 Feb 2012 15:35:44 +0100 Subject: [PATCH 2/5] fixed logo.png -> Logo.png, moved "Graphics" folder name and "Logo.png" file name to CSettings --- Vocaluxe/Base/CSettings.cs | 2 ++ Vocaluxe/Program.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 3fe7b0f6..1578dd23 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -47,6 +47,7 @@ namespace Vocaluxe.Base public static bool bFullScreen = false; public const string sIcon = "Vocaluxe.ico"; + public const string sLogo = "Logo.png"; public const string FallbackLanguage = "English"; public static string sBassRegistration = "Registration.xml"; public static string sFileConfig = "Config.xml"; @@ -62,6 +63,7 @@ namespace Vocaluxe.Base public const string sSoundT440 = "440Hz.mp3"; public const string sFolderCover = "Cover"; + public const string sFolderGraphics = "Graphics"; public const string sFolderFonts = "Fonts"; public const string sFolderThemes = "Themes"; public const string sFolderSkins = "Skins"; diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index f7fb9602..e14caf14 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -173,7 +173,7 @@ namespace Vocaluxe { public SplashScreen() { - string path = Path.Combine(Environment.CurrentDirectory, Path.Combine("Graphics", "logo.png")); + string path = Path.Combine(Environment.CurrentDirectory, Path.Combine(CSettings.sFolderGraphics, CSettings.sLogo)); if (File.Exists(path)) { try From c055fe5e0447563f04092e621275c3119191bd44 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Sat, 25 Feb 2012 06:29:56 +0800 Subject: [PATCH 3/5] Initial conversion support, no UTF8 conversion from USDX 1.01 and CMD Mod yet unfortunately --- Vocaluxe/Base/CDataBase.cs | 161 +++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 84375cca..9db2ee49 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -10,6 +10,7 @@ using System.Data.SQLite; using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Song; +using System.Data; namespace Vocaluxe.Base { @@ -305,6 +306,31 @@ namespace Vocaluxe.Base reader.Dispose(); } + command.CommandText = "PRAGMA user_version"; + reader = command.ExecuteReader(); + reader.Read(); + + int version = reader.GetInt32(0); + + reader.Close(); + reader.Dispose(); + + //Check if old scores table exists + command.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='US_Scores';"; + reader = command.ExecuteReader(); + reader.Read(); + bool scoresTableExists = reader.HasRows; + + reader.Close(); + reader.Dispose(); + + //Check for USDX 1.1 DB + if (version == 1) + ConvertFrom110(); + //Check for USDX 1.01 or CMD Mod DB + else if (version == 0 && scoresTableExists) + ConvertFrom101(); + command.Dispose(); connection.Close(); @@ -359,6 +385,141 @@ namespace Vocaluxe.Base } */ } + + /// + /// Converts a USDX 1.1 database into the Vocaluxe format + /// + /// True if succeeded + private static bool ConvertFrom110() + { + SQLiteConnection connection = new SQLiteConnection(); + connection.ConnectionString = "Data Source=" + _HighscoreFilePath; + SQLiteCommand command; + + try + { + connection.Open(); + } + catch (Exception) + { + return false; + } + + command = new SQLiteCommand(connection); + + //The USDX database has no column for LineNr, Medley and Duet so just fill 0 in there + command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores"; + command.ExecuteNonQuery(); + + command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs"; + command.ExecuteNonQuery(); + + //Delete old tables after conversion + command.CommandText = "DROP TABLE US_Scores;"; + command.ExecuteNonQuery(); + + command.CommandText = "DROP TABLE US_Songs;"; + command.ExecuteNonQuery(); + + command.CommandText = "DROP TABLE us_statistics_info;"; + command.ExecuteNonQuery(); + + //This versioning is not used in Vocaluxe so reset it to 0 + command.CommandText = "PRAGMA user_version = 0"; + command.ExecuteNonQuery(); + + command.Dispose(); + connection.Close(); + connection.Dispose(); + + return true; + } + + /// + /// Converts a USDX 1.01 or CMD 1.01 database to Vocaluxe format + /// + /// True if succeeded + private static bool ConvertFrom101() + { + SQLiteConnection connection = new SQLiteConnection(); + connection.ConnectionString = "Data Source=" + _HighscoreFilePath; + SQLiteCommand command; + SQLiteDataReader reader = null; + + try + { + connection.Open(); + } + catch (Exception) + { + return false; + } + + command = new SQLiteCommand(connection); + + command.CommandText = "PRAGMA table_info(US_Scores);"; + reader = command.ExecuteReader(); + reader.Read(); + + bool dateExists = false; + + //Check for column Date + for (int i = 0; i < reader.FieldCount; i++) + { + if (reader.GetName(i) == "Date") + { + dateExists = true; + break; + } + } + + reader.Close(); + + //This is a USDX 1.01 DB + if(!dateExists) + command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', '0', '0', '0', Difficulty from US_Scores"; + else // This is a CMD 1.01 DB + command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores"; + command.ExecuteNonQuery(); + + command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs"; + command.ExecuteNonQuery(); + + //Delete old tables after conversion + command.CommandText = "DROP TABLE US_Scores;"; + command.ExecuteNonQuery(); + + command.CommandText = "DROP TABLE US_Songs;"; + command.ExecuteNonQuery(); + + //Now loop through all tables and convert from CP1252 to UTF8 + command.CommandText = "SELECT ID, Artist, Title from Songs"; + + //Create a DataTable containing the results + DataTable results = new DataTable(); + SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); + adapter.Fill(results); + + foreach (DataRow row in results.Rows) + { + //FIXME: Convert Latin1(CP1252) to UTF8 + int id = Convert.ToInt32(row.ItemArray[0].ToString()); + string artist = row.ItemArray[1].ToString(); + string title = row.ItemArray[2].ToString(); + + command.CommandText = "UPDATE Songs SET Artist ='" + artist + "', Title = '" + title + "'WHERE ID = " + id; + command.ExecuteNonQuery(); + } + + results.Dispose(); + adapter.Dispose(); + reader.Dispose(); + command.Dispose(); + connection.Close(); + connection.Dispose(); + + return true; + } #endregion Highscores #region Cover From fbd2f2aee342061bca2949157154365da48ff8bb Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Sun, 26 Feb 2012 07:10:36 +0800 Subject: [PATCH 4/5] Some database converting changes --- Vocaluxe/Base/CDataBase.cs | 50 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 9db2ee49..492fee79 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -485,6 +485,32 @@ namespace Vocaluxe.Base command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs"; command.ExecuteNonQuery(); + CLog.LogError("The database has been converted but all non ASCII characters got lost in this process"); + + /* Unfortunately all SQLite Wrappers do convert data to UTF8 when interacting with the database, so converting cant be done in .Net, + * we might have to write a library in C++ which can convert data or just write a simple program to which converts the tables. + */ + + //Now loop through all tables and convert from CP1252 to UTF8 + //command.CommandText = "SELECT ID, Artist, Title from US_Songs"; + + //Create a DataTable containing the results + //DataTable results = new DataTable(); + //SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); + //adapter.Fill(results); + + //foreach (DataRow row in results.Rows) + //{ + // //FIXME: Convert Latin1(CP1252) to UTF8 + // int id = Convert.ToInt32(row.ItemArray[0].ToString()); + // string artist = row.ItemArray[1].ToString(); + // //artist = Encoding.Unicode.GetString(Encoding.Convert(Encoding.GetEncoding(1252), Encoding.Unicode, Encoding.GetEncoding(1252).GetBytes(row.ItemArray[1].ToString()))); + // string title = row.ItemArray[2].ToString(); + + // command.CommandText = "UPDATE Songs SET Artist ='" + artist + "', Title = '" + title + "'WHERE ID = " + id; + // command.ExecuteNonQuery(); + //} + //Delete old tables after conversion command.CommandText = "DROP TABLE US_Scores;"; command.ExecuteNonQuery(); @@ -492,27 +518,9 @@ namespace Vocaluxe.Base command.CommandText = "DROP TABLE US_Songs;"; command.ExecuteNonQuery(); - //Now loop through all tables and convert from CP1252 to UTF8 - command.CommandText = "SELECT ID, Artist, Title from Songs"; - - //Create a DataTable containing the results - DataTable results = new DataTable(); - SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); - adapter.Fill(results); - - foreach (DataRow row in results.Rows) - { - //FIXME: Convert Latin1(CP1252) to UTF8 - int id = Convert.ToInt32(row.ItemArray[0].ToString()); - string artist = row.ItemArray[1].ToString(); - string title = row.ItemArray[2].ToString(); - - command.CommandText = "UPDATE Songs SET Artist ='" + artist + "', Title = '" + title + "'WHERE ID = " + id; - command.ExecuteNonQuery(); - } - - results.Dispose(); - adapter.Dispose(); + //results.Dispose(); + //adapter.Dispose(); + reader.Dispose(); command.Dispose(); connection.Close(); From ebd16304b1cd8b6133aaadd873d10d4533a23fd6 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Sun, 26 Feb 2012 18:32:58 +0100 Subject: [PATCH 5/5] some changes in acinerella class --- Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs | 15 --------------- Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs | 5 +---- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs index 6221f6dd..2b7b1ac3 100644 --- a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs +++ b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs @@ -38,22 +38,7 @@ namespace Vocaluxe.Lib.Video.Acinerella [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct TAc_file_info { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] - public string title; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] - public string author; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] - public string copyright; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] - public string comment; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] - public string album; - public Int32 year; - public Int32 track; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] - public string genre; public Int64 duration; - public Int32 bitrate; } // TAc_instance represents an Acinerella instance. Each instance can open and diff --git a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs index 3dac356e..e6031786 100644 --- a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs @@ -580,7 +580,6 @@ namespace Vocaluxe.Lib.Video return; int FrameFinished = 0; - bool error = false; if (DropFrame && !_BeforeLoop) { try @@ -604,7 +603,6 @@ namespace Vocaluxe.Lib.Video } catch (Exception) { - error = true; CLog.LogError("Error AcGetFrame " + _FileName); } @@ -649,8 +647,7 @@ namespace Vocaluxe.Lib.Video } else { - if (!error) // just a quick and dirty workaround for the mkv seek bug in ffmpeg - _NoMoreFrames = true; + _NoMoreFrames = true; } return; }