Add time debug info. Fix sleep duration for audio sync.

This commit is contained in:
2022-11-12 17:02:21 +08:00
parent a47faf0049
commit 252853f4d4
2 changed files with 16 additions and 2 deletions

View File

@@ -105,6 +105,7 @@ namespace Cryville.Crtr {
bool texloaddone;
diag::Stopwatch texloadtimer = new diag::Stopwatch();
bool firstFrame;
double atime0;
void Update() {
// if (Input.GetKeyDown(KeyCode.Return)) TogglePlay();
if (started) {
@@ -238,6 +239,12 @@ namespace Cryville.Crtr {
UnityEngine.Profiling.Profiler.GetTotalReservedMemory()
#endif
);
if (started) sttext += string.Format(
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
cbus.Time,
Game.AudioClient.Position - atime0,
inputProxy.GetTimestampAverage()
);
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
status.text = sttext;
}
@@ -401,8 +408,8 @@ namespace Cryville.Crtr {
timer.Stop();
Logger.Log("main", 1, "Load/Prehandle", "Prehandling done ({0}ms)", timer.Elapsed.TotalMilliseconds);
Game.AudioSequencer.Playing = true;
Thread.Sleep((int)(Game.AudioClient.BufferPosition - Game.AudioClient.Position));
// TODO SyncTime(cbus.Time);
atime0 = Game.AudioClient.BufferPosition;
Thread.Sleep((int)((atime0 - Game.AudioClient.Position) * 1000));
inputProxy.SyncTime(cbus.Time);
started = true;
}