Skip to content
Snippets Groups Projects
Commit 61da84fc authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix for negative timestamps in ftl files

parent 2ac65772
No related branches found
No related tags found
No related merge requests found
Pipeline #21049 passed
......@@ -66,6 +66,7 @@ class File : public Stream {
int64_t timestart_;
int64_t timestamp_;
int64_t interval_;
int64_t first_ts_;
bool active_;
int version_;
ftl::timer::TimerHandle timer_;
......
......@@ -41,6 +41,7 @@ bool File::_checkFile() {
int count = 10;
int64_t ts = -1000;
int min_ts_diff = 1000;
first_ts_ = 10000000;
while (count > 0) {
std::tuple<ftl::codecs::StreamPacket,ftl::codecs::Packet> data;
......@@ -51,6 +52,8 @@ bool File::_checkFile() {
auto &spkt = std::get<0>(data);
auto &pkt = std::get<1>(data);
if (spkt.timestamp < first_ts_) first_ts_ = spkt.timestamp;
if (spkt.timestamp > 0 && int(spkt.channel) < 32) {
if (spkt.timestamp > ts) {
--count;
......@@ -219,7 +222,7 @@ bool File::tick(int64_t ts) {
// Adjust timestamp
// FIXME: A potential bug where multiple times are merged into one?
std::get<0>(data).timestamp = ((std::get<0>(data).timestamp) / interval_) * interval_ + timestart_;
std::get<0>(data).timestamp = (((std::get<0>(data).timestamp) - first_ts_) / interval_) * interval_ + timestart_;
// Maintain availability of channels.
available(0) += std::get<0>(data).channel;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment