From 3d7bdaeb5d20f75e1eaf1903027cfc0d6644aec3 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sun, 26 Jul 2020 21:40:36 +0300
Subject: [PATCH] Fix ftl file local timestamps

---
 components/common/cpp/src/timer.cpp   | 2 ++
 components/streams/src/filestream.cpp | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/components/common/cpp/src/timer.cpp b/components/common/cpp/src/timer.cpp
index 8b83ef6ec..b249b0f6c 100644
--- a/components/common/cpp/src/timer.cpp
+++ b/components/common/cpp/src/timer.cpp
@@ -130,6 +130,8 @@ static void waitTimePoint() {
 		now = get_time();
 	}
 	last_frame = now/mspf;
+	int64_t over = now - (last_frame*mspf);
+	if (over > 1) LOG(WARNING) << "Timer off by " << over << "ms";
 }
 
 void ftl::timer::setInterval(int ms) {
diff --git a/components/streams/src/filestream.cpp b/components/streams/src/filestream.cpp
index 61db4ce84..d7ac4bcf9 100644
--- a/components/streams/src/filestream.cpp
+++ b/components/streams/src/filestream.cpp
@@ -206,7 +206,6 @@ void File::_patchPackets(ftl::codecs::StreamPacket &spkt, ftl::codecs::Packet &p
 	}
 
 	spkt.version = 5;
-	spkt.localTimestamp = spkt.timestamp;
 
 	// Fix for flags corruption
 	if (pkt.data.size() == 0) {
@@ -247,6 +246,8 @@ bool File::tick(int64_t ts) {
 					auto &spkt = std::get<0>(*i);
 					auto &pkt = std::get<1>(*i);
 
+					spkt.localTimestamp = spkt.timestamp;
+
 					try {
 						cb_.trigger(spkt, pkt);
 					} catch (const ftl::exception &e) {
-- 
GitLab