diff --git a/Output/Community.CsharpSqlite.dll b/Output/Community.CsharpSqlite.dll
new file mode 100644
index 00000000..3284e06f
Binary files /dev/null and b/Output/Community.CsharpSqlite.dll differ
diff --git a/Output/Vocaluxe.exe.config b/Output/Vocaluxe.exe.config
new file mode 100644
index 00000000..4e4db22f
--- /dev/null
+++ b/Output/Vocaluxe.exe.config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Output/acinerella.dll b/Output/acinerella.dll
index 22ef1d4e..e713c09f 100644
Binary files a/Output/acinerella.dll and b/Output/acinerella.dll differ
diff --git a/Output/libacinerella.so b/Output/libacinerella.so
index 30eb1ce7..eb9aa580 100644
Binary files a/Output/libacinerella.so and b/Output/libacinerella.so differ
diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs
index 2674a093..bc984dc7 100644
--- a/Vocaluxe/Base/CDataBase.cs
+++ b/Vocaluxe/Base/CDataBase.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
@@ -7,15 +8,23 @@ using System.IO;
using System.Text;
using System.Data.SQLite;
+using Community.CsharpSqlite;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Lib.Song;
-using System.Data;
namespace Vocaluxe.Base
{
static class CDataBase
{
+ struct SData
+ {
+ public int id;
+ public long ticks;
+ public string str1;
+ public string str2;
+ }
+
private static string _HighscoreFilePath;
private static string _CoverFilePath;
private static string _CreditsRessourcesFilePath;
@@ -417,6 +426,79 @@ namespace Vocaluxe.Base
command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs";
command.ExecuteNonQuery();
+ List scores = new List();
+ List songs = new List();
+
+ SQLiteDataReader reader = null;
+ command.CommandText = "SELECT id, PlayerName, Date FROM Scores";
+ try
+ {
+ reader = command.ExecuteReader();
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+
+ if (reader != null && reader.HasRows)
+ {
+ while (reader.Read())
+ {
+ SData data = new SData();
+ data.id = reader.GetInt32(0);
+ data.str1 = reader.GetString(1);
+ data.ticks = UnixTimeToTicks((int)reader.GetInt64(2));
+
+ scores.Add(data);
+ }
+ reader.Close();
+ }
+
+ command.CommandText = "SELECT id, Artist, Title FROM Songs";
+ try
+ {
+ reader = command.ExecuteReader();
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+
+ if (reader != null && reader.HasRows)
+ {
+ while (reader.Read())
+ {
+ SData data = new SData();
+ data.id = reader.GetInt32(0);
+ data.str1 = reader.GetString(1);
+ data.str2 = reader.GetString(2);
+ songs.Add(data);
+ }
+ reader.Close();
+ }
+
+ reader.Dispose();
+
+ // update Title and Artist strings
+ foreach (SData data in songs)
+ {
+ command.CommandText = "UPDATE Songs SET [Artist] = @artist, [Title] = @title WHERE [ID] = @id";
+ command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = data.str2;
+ command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = data.str1;
+ command.Parameters.Add("@id", System.Data.DbType.Int32, 0).Value = data.id;
+ command.ExecuteNonQuery();
+ }
+
+ // update player names
+ foreach (SData data in scores)
+ {
+ command.CommandText = "UPDATE Scores SET [PlayerName] = @player, [Date] = @date WHERE [id] = @id";
+ command.Parameters.Add("@player", System.Data.DbType.String, 0).Value = data.str1;
+ command.Parameters.Add("@date", System.Data.DbType.Int64, 0).Value = data.ticks;
+ command.Parameters.Add("@id", System.Data.DbType.Int32, 0).Value = data.id;
+ command.ExecuteNonQuery();
+ }
+
//Delete old tables after conversion
command.CommandText = "DROP TABLE US_Scores;";
command.ExecuteNonQuery();
@@ -462,19 +544,24 @@ namespace Vocaluxe.Base
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++)
+ while (reader.Read())
{
- if (reader.GetName(i) == "Date")
+ for (int i = 0; i < reader.FieldCount; i++)
{
- dateExists = true;
- break;
+ if (reader.GetName(i) == "name")
+ {
+ if (reader.GetString(i) == "Date")
+ dateExists = true;
+ break;
+ }
}
}
+
reader.Close();
@@ -488,31 +575,112 @@ 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");
+ // convert from CP1252 to UTF8
+ List scores = new List();
+ List songs = new List();
- /* 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";
+ Sqlite3.sqlite3 OldDB;
+ int res = Sqlite3.sqlite3_open(_HighscoreFilePath, out OldDB);
- //Create a DataTable containing the results
- //DataTable results = new DataTable();
- //SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
- //adapter.Fill(results);
+ if (res != Sqlite3.SQLITE_OK)
+ {
+ CLog.LogError("Error opening Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
+ }
+ else
+ {
+ Sqlite3.Vdbe Stmt = new Sqlite3.Vdbe();
+ res = Sqlite3.sqlite3_prepare_v2(OldDB, "SELECT ID, Artist, Title FROM US_Songs", -1, ref Stmt, 0);
- //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();
+ if (res != Sqlite3.SQLITE_OK)
+ {
+ CLog.LogError("Error query Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
+ }
+ else
+ {
+ Sqlite3.sqlite3_step(Stmt);
- // command.CommandText = "UPDATE Songs SET Artist ='" + artist + "', Title = '" + title + "'WHERE ID = " + id;
- // command.ExecuteNonQuery();
- //}
+ Encoding UTF8 = Encoding.UTF8;
+ Encoding CP1252 = Encoding.GetEncoding(1252);
+
+ while (Sqlite3.sqlite3_step(Stmt) == Sqlite3.SQLITE_ROW)
+ {
+ SData data = new SData();
+
+ data.id = Sqlite3.sqlite3_column_int(Stmt, 0);
+
+ byte[] bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 1);
+ data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
+
+ bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 2);
+ data.str2 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
+
+ songs.Add(data);
+ }
+ Sqlite3.sqlite3_finalize(Stmt);
+ }
+
+ Stmt = new Sqlite3.Vdbe();
+
+ if (!dateExists)
+ res = Sqlite3.sqlite3_prepare_v2(OldDB, "SELECT rowid, Player FROM US_Scores", -1, ref Stmt, 0);
+ else
+ res = Sqlite3.sqlite3_prepare_v2(OldDB, "SELECT rowid, Player, Date FROM US_Scores", -1, ref Stmt, 0);
+
+ if (res != Sqlite3.SQLITE_OK)
+ {
+ CLog.LogError("Error query Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
+ }
+ else
+ {
+ Sqlite3.sqlite3_step(Stmt);
+
+ Encoding UTF8 = Encoding.UTF8;
+ Encoding CP1252 = Encoding.GetEncoding(1252);
+
+ while (Sqlite3.sqlite3_step(Stmt) == Sqlite3.SQLITE_ROW)
+ {
+ SData data = new SData();
+
+ data.id = Sqlite3.sqlite3_column_int(Stmt, 0);
+
+ byte[] bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 1);
+ data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
+
+ if (dateExists)
+ data.ticks = UnixTimeToTicks(Sqlite3.sqlite3_column_int(Stmt, 2));
+
+ scores.Add(data);
+ }
+ Sqlite3.sqlite3_finalize(Stmt);
+ }
+ }
+
+ Sqlite3.sqlite3_close(OldDB);
+
+ // update Title and Artist strings
+ foreach (SData data in songs)
+ {
+ command.CommandText = "UPDATE Songs SET [Artist] = @artist, [Title] = @title WHERE [ID] = @id";
+ command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = data.str2;
+ command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = data.str1;
+ command.Parameters.Add("@id", System.Data.DbType.Int32, 0).Value = data.id;
+ command.ExecuteNonQuery();
+ }
+
+ // update player names
+ foreach (SData data in scores)
+ {
+ if (!dateExists)
+ command.CommandText = "UPDATE Scores SET [PlayerName] = @player WHERE [id] = @id";
+ else
+ {
+ command.CommandText = "UPDATE Scores SET [PlayerName] = @player, [Date] = @date WHERE [id] = @id";
+ command.Parameters.Add("@date", System.Data.DbType.Int64, 0).Value = data.ticks;
+ }
+ command.Parameters.Add("@player", System.Data.DbType.String, 0).Value = data.str1;
+ command.Parameters.Add("@id", System.Data.DbType.Int32, 0).Value = data.id;
+ command.ExecuteNonQuery();
+ }
//Delete old tables after conversion
command.CommandText = "DROP TABLE US_Scores;";
@@ -520,9 +688,6 @@ namespace Vocaluxe.Base
command.CommandText = "DROP TABLE US_Songs;";
command.ExecuteNonQuery();
-
- //results.Dispose();
- //adapter.Dispose();
reader.Dispose();
command.Dispose();
@@ -1070,5 +1235,12 @@ namespace Vocaluxe.Base
return stream.ToArray();
}
}
+
+ private static long UnixTimeToTicks(int UnixTime)
+ {
+ DateTime t70 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
+ t70 = t70.AddSeconds(UnixTime);
+ return t70.Ticks;
+ }
}
}
diff --git a/Vocaluxe/Lib/Video/Acinerella/acinerella.c b/Vocaluxe/Lib/Video/Acinerella/acinerella.c
index b0562631..c5b23ef7 100644
--- a/Vocaluxe/Lib/Video/Acinerella/acinerella.c
+++ b/Vocaluxe/Lib/Video/Acinerella/acinerella.c
@@ -105,16 +105,7 @@ typedef ac_package_data* lp_ac_package_data;
void init_info(lp_ac_file_info info)
{
- info->title[0] = 0;
- info->author[0] = 0;
- info->copyright[0] = 0;
- info->comment[0] = 0;
- info->album[0] = 0;
- info->year = -1;
- info->track = -1;
- info->genre[0] = 0;
info->duration = -1;
- info->bitrate = -1;
}
int av_initialized = 0;
@@ -361,20 +352,7 @@ int CALL_CONVT ac_open(
//Retrieve stream information
AVFormatContext *ctx = ((lp_ac_data)pacInstance)->pFormatCtx;
- if(avformat_find_stream_info(ctx, NULL) >= 0) {
- /*
- strcpy(pacInstance->info.title, ctx->title);
- strcpy(pacInstance->info.author, ctx->author);
- strcpy(pacInstance->info.copyright, ctx->copyright);
- strcpy(pacInstance->info.comment, ctx->comment);
- strcpy(pacInstance->info.album, ctx->album);
- strcpy(pacInstance->info.genre, ctx->genre);
-
- pacInstance->info.year = ctx->year;
- pacInstance->info.track = ctx->track;
- pacInstance->info.bitrate = ctx->bit_rate;
- */
-
+ if(avformat_find_stream_info(ctx, NULL) >= 0) {
pacInstance->info.duration = ctx->duration * 1000 / AV_TIME_BASE;
} else {
return -1;
@@ -658,16 +636,17 @@ double ac_sync_video(lp_ac_package pPackage, lp_ac_decoder pDec, AVFrame *src_fr
}
int ac_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder, lp_ac_decoder pDec) {
- int finished;
- double pts;
+ if (((lp_ac_package_data)pPackage)->ffpackage.size <= 0)
+ return 0;
+
+ int finished = 0;
+ double pts = 0;
avcodec_decode_video2(
pDecoder->pCodecCtx, pDecoder->pFrame, &finished,
- &(((lp_ac_package_data)pPackage)->ffpackage));
-
+ &(((lp_ac_package_data)pPackage)->ffpackage));
+
if (finished) {
- pts=0;
-
if(((lp_ac_package_data)pPackage)->ffpackage.dts == AV_NOPTS_VALUE &&
*(uint64_t*)pDecoder->pFrame->opaque != AV_NOPTS_VALUE ){
pts = *(uint64_t*)pDecoder->pFrame->opaque;
diff --git a/Vocaluxe/Lib/Video/Acinerella/acinerella.h b/Vocaluxe/Lib/Video/Acinerella/acinerella.h
index bfa8773c..203d8750 100644
--- a/Vocaluxe/Lib/Video/Acinerella/acinerella.h
+++ b/Vocaluxe/Lib/Video/Acinerella/acinerella.h
@@ -68,21 +68,8 @@ typedef enum _ac_output_format ac_output_format;
/*Contains information about the whole file/stream that has been opened. Default values are ""
for strings and -1 for integer values.*/
struct _ac_file_info {
- /*Information about the file*/
- char title[512];
- char author[512];
- char copyright[512];
- char comment[512];
- char album[512];
- int year;
- int track;
- char genre[32];
-
/*Length of the file*/
int64_t duration;
-
- /*Bitrate*/
- int bitrate;
};
typedef struct _ac_file_info ac_file_info;
diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj
index 01576595..be43254c 100644
--- a/Vocaluxe/Vocaluxe.csproj
+++ b/Vocaluxe/Vocaluxe.csproj
@@ -58,6 +58,10 @@
False
..\Output\Bass.Net.dll
+
+ False
+ ..\Output\Community.CsharpSqlite.dll
+
False
..\Output\NAudio.dll