NBLog exchange author and timestamp positions in log

Bug: 36366826
Test: no change in functionality
Change-Id: I137695b57b9f2b84d6059b37972e06b115e10d1f
diff --git a/media/libnbaio/NBLog.cpp b/media/libnbaio/NBLog.cpp
index 7936ad2..de38e7f 100644
--- a/media/libnbaio/NBLog.cpp
+++ b/media/libnbaio/NBLog.cpp
@@ -68,24 +68,32 @@
 
 NBLog::FormatEntry::iterator NBLog::FormatEntry::args() const {
     auto it = begin();
-    // Second entry can be author or timestamp. Skip author if present
-    if ((++it)->type == EVENT_AUTHOR) {
+    // skip start fmt
+    ++it;
+    // skip timestamp
+    ++it;
+    // Skip author if present
+    if (it->type == EVENT_AUTHOR) {
         ++it;
     }
-    return ++it;
+    return it;
 }
 
 timespec NBLog::FormatEntry::timestamp() const {
     auto it = begin();
-    if ((++it)->type != EVENT_TIMESTAMP) {
-        ++it;
-    }
+    // skip start fmt
+    ++it;
     return it.payload<timespec>();
 }
 
 pid_t NBLog::FormatEntry::author() const {
     auto it = begin();
-    if ((++it)->type == EVENT_AUTHOR) {
+    // skip start fmt
+    ++it;
+    // skip timestamp
+    ++it;
+    // if there is an author entry, return it, return -1 otherwise
+    if (it->type == EVENT_AUTHOR) {
         return it.payload<int>();
     }
     return -1;
@@ -96,6 +104,8 @@
     auto it = begin();
     // copy fmt start entry
     it.copyTo(dst);
+    // copy timestamp
+    (++it).copyTo(dst);
     // insert author entry
     size_t authorEntrySize = NBLog::Entry::kOverhead + sizeof(author);
     uint8_t authorEntry[authorEntrySize];
diff --git a/media/libnbaio/include/NBLog.h b/media/libnbaio/include/NBLog.h
index 7aaf298..59b77bd 100644
--- a/media/libnbaio/include/NBLog.h
+++ b/media/libnbaio/include/NBLog.h
@@ -59,8 +59,8 @@
 
 // a formatted entry has the following structure:
 //    * START_FMT entry, containing the format string
-//    * author entry of the thread that generated it (optional, present in merged log)
 //    * TIMESTAMP entry
+//    * author entry of the thread that generated it (optional, present in merged log)
 //    * format arg1
 //    * format arg2
 //    * ...