Separate merge from dump and call merge periodically

Every time merge is called by the thread loop,
the data is also processed and written to
PerformanceAnalysis. A call to dump retrieves
the FIFO of processed data in PerformanceAnalysis
instead of the unprocessed Reader FIFO, and prints
the result to the console.

Test: dumpsys media.log

Change-Id: Ic479f48e9e4fdf4523a8f15db514dbdd85b70434
diff --git a/media/libnbaio/ReportPerformance.cpp b/media/libnbaio/ReportPerformance.cpp
index dc50ada..7d3869c 100644
--- a/media/libnbaio/ReportPerformance.cpp
+++ b/media/libnbaio/ReportPerformance.cpp
@@ -38,8 +38,8 @@
 
 // Writes outlier intervals, timestamps, and histograms spanning long time intervals to a file.
 // TODO: format the data efficiently and write different types of data to different files
-void writeToFile(std::deque<std::pair<outlierInterval, timestamp>> &outlierData,
-                                    std::deque<std::pair<timestamp, Histogram>> &hists,
+void writeToFile(const std::deque<std::pair<outlierInterval, timestamp>> &outlierData,
+                                    const std::deque<std::pair<timestamp, Histogram>> &hists,
                                     const char * kName,
                                     bool append) {
     ALOGD("writing performance data to file");
@@ -65,6 +65,7 @@
         for (const auto &bucket : hist.second) {
             ofs << bucket.first << ": " << bucket.second << "\n";
         }
+        ofs << "\n"; // separate histograms with a newline
     }
     ofs.close();
 }