Handle a node not having a start time

We don't populate the start time of a log file when we don't know what
time it is on the remote node.  This was leading to us queueing data
relative to the start of time, not the start of the data.

To start with, queue relative to the max of the start time or the
timestamp of the first piece of data.  This will make sure we have
enough data to support sorting.

A follow-up change needs to handle queueing until the start better.

Change-Id: If719a7221d7a3b15992a77d48b398d1344c60c17
diff --git a/aos/events/logging/logger.cc b/aos/events/logging/logger.cc
index 8c6d936..6f722bc 100644
--- a/aos/events/logging/logger.cc
+++ b/aos/events/logging/logger.cc
@@ -2105,10 +2105,10 @@
 
 void LogReader::State::SeedSortedMessages() {
   if (!timestamp_mapper_) return;
-  const aos::monotonic_clock::time_point end_queue_time =
-      (sorted_messages_.size() > 0
-           ? std::get<0>(sorted_messages_.front()).monotonic_event_time
-           : timestamp_mapper_->monotonic_start_time()) +
+  aos::monotonic_clock::time_point end_queue_time =
+      (sorted_messages_.empty()
+           ? timestamp_mapper_->monotonic_start_time()
+           : std::get<0>(sorted_messages_.front()).monotonic_event_time) +
       chrono::duration_cast<chrono::seconds>(
           chrono::duration<double>(FLAGS_time_estimation_buffer_seconds));
 
@@ -2117,14 +2117,26 @@
     if (m == nullptr) {
       return;
     }
-    if (sorted_messages_.size() > 0) {
+    if (!sorted_messages_.empty()) {
       // Stop placing sorted messages on the list once we have
       // --time_estimation_buffer_seconds seconds queued up (but queue at least
-      // until the log starts.
+      // until the log starts).  Only break if the queue isn't empty to make
+      // sure something is always queued.
       if (end_queue_time <
           std::get<0>(sorted_messages_.back()).monotonic_event_time) {
         return;
       }
+    } else {
+      // If we were empty, there's a chance the start time was
+      // monotonic_clock::min_time if the log file had no idea of the start.  In
+      // that case, we want to queue --time_estimation_buffer_seconds from the
+      // first message.  The most conservative thing to do is to take the max of
+      // that duration and the one computed using the start time.
+      end_queue_time = std::max(
+          end_queue_time,
+          m->monotonic_event_time +
+              chrono::duration_cast<chrono::seconds>(chrono::duration<double>(
+                  FLAGS_time_estimation_buffer_seconds)));
     }
 
     message_bridge::NoncausalOffsetEstimator *filter = nullptr;