Improves resolution when logging rate in the ADB class.

Trivial patch which fixes an issue where logged rate estimates could be
invalid. E.g. on iOS, two successive timer interrupts can be ~10.5 seconds
and not exactly 10.0 (which is usually the case on Android). In those
cases we could log a rate estimate of e.g. ~51000Hz instead of ~48000Hz.

This CL fixes that.

BUG=NONE

Review-Url: https://codereview.webrtc.org/2350103002
Cr-Commit-Position: refs/heads/master@{#14305}
diff --git a/webrtc/modules/audio_device/audio_device_buffer.cc b/webrtc/modules/audio_device/audio_device_buffer.cc
index 0c85fda..77cc741 100644
--- a/webrtc/modules/audio_device/audio_device_buffer.cc
+++ b/webrtc/modules/audio_device/audio_device_buffer.cc
@@ -398,25 +398,25 @@
   // Log the latest statistics but skip the first 10 seconds since we are not
   // sure of the exact starting point. I.e., the first log printout will be
   // after ~20 seconds.
-  if (++num_stat_reports_ > 1) {
+  if (++num_stat_reports_ > 1 && time_since_last > 0) {
     uint32_t diff_samples = rec_samples_ - last_rec_samples_;
-    uint32_t rate = diff_samples / kTimerIntervalInSeconds;
+    float rate = diff_samples / (static_cast<float>(time_since_last) / 1000.0);
     LOG(INFO) << "[REC : " << time_since_last << "msec, "
               << rec_sample_rate_ / 1000
               << "kHz] callbacks: " << rec_callbacks_ - last_rec_callbacks_
               << ", "
               << "samples: " << diff_samples << ", "
-              << "rate: " << rate << ", "
+              << "rate: " << static_cast<int>(rate + 0.5) << ", "
               << "level: " << max_rec_level_;
 
     diff_samples = play_samples_ - last_play_samples_;
-    rate = diff_samples / kTimerIntervalInSeconds;
+    rate = diff_samples / (static_cast<float>(time_since_last) / 1000.0);
     LOG(INFO) << "[PLAY: " << time_since_last << "msec, "
               << play_sample_rate_ / 1000
               << "kHz] callbacks: " << play_callbacks_ - last_play_callbacks_
               << ", "
               << "samples: " << diff_samples << ", "
-              << "rate: " << rate << ", "
+              << "rate: " << static_cast<int>(rate + 0.5) << ", "
               << "level: " << max_play_level_;
   }