Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: webrtc/modules/audio_device/audio_device_buffer.cc

Issue 2350103002: Improves resolution when logging rate in the ADB class (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 RTC_DCHECK(task_queue_.IsCurrent()); 391 RTC_DCHECK(task_queue_.IsCurrent());
392 392
393 int64_t now_time = rtc::TimeMillis(); 393 int64_t now_time = rtc::TimeMillis();
394 int64_t next_callback_time = now_time + kTimerIntervalInMilliseconds; 394 int64_t next_callback_time = now_time + kTimerIntervalInMilliseconds;
395 int64_t time_since_last = rtc::TimeDiff(now_time, last_log_stat_time_); 395 int64_t time_since_last = rtc::TimeDiff(now_time, last_log_stat_time_);
396 last_log_stat_time_ = now_time; 396 last_log_stat_time_ = now_time;
397 397
398 // Log the latest statistics but skip the first 10 seconds since we are not 398 // Log the latest statistics but skip the first 10 seconds since we are not
399 // sure of the exact starting point. I.e., the first log printout will be 399 // sure of the exact starting point. I.e., the first log printout will be
400 // after ~20 seconds. 400 // after ~20 seconds.
401 if (++num_stat_reports_ > 1) { 401 if (++num_stat_reports_ > 1) {
hlundin-webrtc 2016/09/20 07:30:25 You should add && time_since_last > 0 to the if st
henrika_webrtc 2016/09/20 09:05:32 Thanks!
402 uint32_t diff_samples = rec_samples_ - last_rec_samples_; 402 uint32_t diff_samples = rec_samples_ - last_rec_samples_;
403 uint32_t rate = diff_samples / kTimerIntervalInSeconds; 403 float rate = diff_samples / (static_cast<float>(time_since_last) / 1000.0);
404 LOG(INFO) << "[REC : " << time_since_last << "msec, " 404 LOG(INFO) << "[REC : " << time_since_last << "msec, "
405 << rec_sample_rate_ / 1000 405 << rec_sample_rate_ / 1000
406 << "kHz] callbacks: " << rec_callbacks_ - last_rec_callbacks_ 406 << "kHz] callbacks: " << rec_callbacks_ - last_rec_callbacks_
407 << ", " 407 << ", "
408 << "samples: " << diff_samples << ", " 408 << "samples: " << diff_samples << ", "
409 << "rate: " << rate << ", " 409 << "rate: " << static_cast<int>(rate + 0.5) << ", "
410 << "level: " << max_rec_level_; 410 << "level: " << max_rec_level_;
411 411
412 diff_samples = play_samples_ - last_play_samples_; 412 diff_samples = play_samples_ - last_play_samples_;
413 rate = diff_samples / kTimerIntervalInSeconds; 413 rate = diff_samples / (static_cast<float>(time_since_last) / 1000.0);
414 LOG(INFO) << "[PLAY: " << time_since_last << "msec, " 414 LOG(INFO) << "[PLAY: " << time_since_last << "msec, "
415 << play_sample_rate_ / 1000 415 << play_sample_rate_ / 1000
416 << "kHz] callbacks: " << play_callbacks_ - last_play_callbacks_ 416 << "kHz] callbacks: " << play_callbacks_ - last_play_callbacks_
417 << ", " 417 << ", "
418 << "samples: " << diff_samples << ", " 418 << "samples: " << diff_samples << ", "
419 << "rate: " << rate << ", " 419 << "rate: " << static_cast<int>(rate + 0.5) << ", "
420 << "level: " << max_play_level_; 420 << "level: " << max_play_level_;
421 } 421 }
422 422
423 // Count number of times we detect "no audio" corresponding to a case where 423 // Count number of times we detect "no audio" corresponding to a case where
424 // all level measurements have been zero. 424 // all level measurements have been zero.
425 if (max_rec_level_ == 0) { 425 if (max_rec_level_ == 0) {
426 ++num_rec_level_is_zero_; 426 ++num_rec_level_is_zero_;
427 } 427 }
428 428
429 last_rec_callbacks_ = rec_callbacks_; 429 last_rec_callbacks_ = rec_callbacks_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 int16_t max_abs = WebRtcSpl_MaxAbsValueW16( 490 int16_t max_abs = WebRtcSpl_MaxAbsValueW16(
491 static_cast<int16_t*>(const_cast<void*>(audio_buffer)), 491 static_cast<int16_t*>(const_cast<void*>(audio_buffer)),
492 num_samples * play_channels_); 492 num_samples * play_channels_);
493 if (max_abs > max_play_level_) { 493 if (max_abs > max_play_level_) {
494 max_play_level_ = max_abs; 494 max_play_level_ = max_abs;
495 } 495 }
496 } 496 }
497 } 497 }
498 498
499 } // namespace webrtc 499 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698