OLD | NEW |
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 last_rec_samples_(0), | 61 last_rec_samples_(0), |
62 play_samples_(0), | 62 play_samples_(0), |
63 last_play_samples_(0), | 63 last_play_samples_(0), |
64 max_rec_level_(0), | 64 max_rec_level_(0), |
65 max_play_level_(0), | 65 max_play_level_(0), |
66 last_timer_task_time_(0), | 66 last_timer_task_time_(0), |
67 rec_stat_count_(0), | 67 rec_stat_count_(0), |
68 play_stat_count_(0), | 68 play_stat_count_(0), |
69 play_start_time_(0), | 69 play_start_time_(0), |
70 rec_start_time_(0), | 70 rec_start_time_(0), |
71 only_silence_recorded_(true) { | 71 only_silence_recorded_(true), |
| 72 log_stats_(false) { |
72 LOG(INFO) << "AudioDeviceBuffer::ctor"; | 73 LOG(INFO) << "AudioDeviceBuffer::ctor"; |
73 playout_thread_checker_.DetachFromThread(); | 74 playout_thread_checker_.DetachFromThread(); |
74 recording_thread_checker_.DetachFromThread(); | 75 recording_thread_checker_.DetachFromThread(); |
75 } | 76 } |
76 | 77 |
77 AudioDeviceBuffer::~AudioDeviceBuffer() { | 78 AudioDeviceBuffer::~AudioDeviceBuffer() { |
78 RTC_DCHECK_RUN_ON(&main_thread_checker_); | 79 RTC_DCHECK_RUN_ON(&main_thread_checker_); |
79 RTC_DCHECK(!playing_); | 80 RTC_DCHECK(!playing_); |
80 RTC_DCHECK(!recording_); | 81 RTC_DCHECK(!recording_); |
81 LOG(INFO) << "AudioDeviceBuffer::~dtor"; | 82 LOG(INFO) << "AudioDeviceBuffer::~dtor"; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 } | 423 } |
423 | 424 |
424 void AudioDeviceBuffer::StopPeriodicLogging() { | 425 void AudioDeviceBuffer::StopPeriodicLogging() { |
425 task_queue_.PostTask(rtc::Bind(&AudioDeviceBuffer::LogStats, this, | 426 task_queue_.PostTask(rtc::Bind(&AudioDeviceBuffer::LogStats, this, |
426 AudioDeviceBuffer::LOG_STOP)); | 427 AudioDeviceBuffer::LOG_STOP)); |
427 } | 428 } |
428 | 429 |
429 void AudioDeviceBuffer::LogStats(LogState state) { | 430 void AudioDeviceBuffer::LogStats(LogState state) { |
430 RTC_DCHECK_RUN_ON(&task_queue_); | 431 RTC_DCHECK_RUN_ON(&task_queue_); |
431 int64_t now_time = rtc::TimeMillis(); | 432 int64_t now_time = rtc::TimeMillis(); |
| 433 |
432 if (state == AudioDeviceBuffer::LOG_START) { | 434 if (state == AudioDeviceBuffer::LOG_START) { |
433 // Reset counters at start. We will not add any logging in this state but | 435 // Reset counters at start. We will not add any logging in this state but |
434 // the timer will started by posting a new (delayed) task. | 436 // the timer will started by posting a new (delayed) task. |
435 num_stat_reports_ = 0; | 437 num_stat_reports_ = 0; |
436 last_timer_task_time_ = now_time; | 438 last_timer_task_time_ = now_time; |
| 439 log_stats_ = true; |
437 } else if (state == AudioDeviceBuffer::LOG_STOP) { | 440 } else if (state == AudioDeviceBuffer::LOG_STOP) { |
438 // Stop logging and posting new tasks. | 441 // Stop logging and posting new tasks. |
| 442 log_stats_ = false; |
| 443 } else if (state == AudioDeviceBuffer::LOG_ACTIVE) { |
| 444 // Keep logging unless logging was disabled while task was posted. |
| 445 } |
| 446 |
| 447 // Avoid adding more logs since we are in STOP mode. |
| 448 if (!log_stats_) { |
439 return; | 449 return; |
440 } else if (state == AudioDeviceBuffer::LOG_ACTIVE) { | |
441 // Default state. Just keep on logging. | |
442 } | 450 } |
443 | 451 |
444 int64_t next_callback_time = now_time + kTimerIntervalInMilliseconds; | 452 int64_t next_callback_time = now_time + kTimerIntervalInMilliseconds; |
445 int64_t time_since_last = rtc::TimeDiff(now_time, last_timer_task_time_); | 453 int64_t time_since_last = rtc::TimeDiff(now_time, last_timer_task_time_); |
446 last_timer_task_time_ = now_time; | 454 last_timer_task_time_ = now_time; |
447 | 455 |
448 // Log the latest statistics but skip the first round just after state was | 456 // Log the latest statistics but skip the first round just after state was |
449 // set to LOG_START. Hence, first printed log will be after ~10 seconds. | 457 // set to LOG_START. Hence, first printed log will be after ~10 seconds. |
450 if (++num_stat_reports_ > 1 && time_since_last > 0) { | 458 if (++num_stat_reports_ > 1 && time_since_last > 0) { |
451 uint32_t diff_samples = rec_samples_ - last_rec_samples_; | 459 uint32_t diff_samples = rec_samples_ - last_rec_samples_; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 size_t samples_per_channel) { | 525 size_t samples_per_channel) { |
518 RTC_DCHECK_RUN_ON(&task_queue_); | 526 RTC_DCHECK_RUN_ON(&task_queue_); |
519 ++play_callbacks_; | 527 ++play_callbacks_; |
520 play_samples_ += samples_per_channel; | 528 play_samples_ += samples_per_channel; |
521 if (max_abs > max_play_level_) { | 529 if (max_abs > max_play_level_) { |
522 max_play_level_ = max_abs; | 530 max_play_level_ = max_abs; |
523 } | 531 } |
524 } | 532 } |
525 | 533 |
526 } // namespace webrtc | 534 } // namespace webrtc |
OLD | NEW |