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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 int16_t max_abs = 0; | 369 int16_t max_abs = 0; |
370 RTC_DCHECK_LT(play_stat_count_, 50); | 370 RTC_DCHECK_LT(play_stat_count_, 50); |
371 if (++play_stat_count_ >= 50) { | 371 if (++play_stat_count_ >= 50) { |
372 // Returns the largest absolute value in a signed 16-bit vector. | 372 // Returns the largest absolute value in a signed 16-bit vector. |
373 max_abs = | 373 max_abs = |
374 WebRtcSpl_MaxAbsValueW16(play_buffer_.data(), play_buffer_.size()); | 374 WebRtcSpl_MaxAbsValueW16(play_buffer_.data(), play_buffer_.size()); |
375 play_stat_count_ = 0; | 375 play_stat_count_ = 0; |
376 } | 376 } |
377 // Update playout stats which is used as base for periodic logging of the | 377 // Update playout stats which is used as base for periodic logging of the |
378 // audio output state. | 378 // audio output state. |
379 UpdatePlayStats(max_abs, num_samples_out); | 379 UpdatePlayStats(max_abs, num_samples_out / play_channels_); |
380 return static_cast<int32_t>(num_samples_out); | 380 return static_cast<int32_t>(num_samples_out / play_channels_); |
381 } | 381 } |
382 | 382 |
383 int32_t AudioDeviceBuffer::GetPlayoutData(void* audio_buffer) { | 383 int32_t AudioDeviceBuffer::GetPlayoutData(void* audio_buffer) { |
384 RTC_DCHECK_RUN_ON(&playout_thread_checker_); | 384 RTC_DCHECK_RUN_ON(&playout_thread_checker_); |
385 RTC_DCHECK_GT(play_buffer_.size(), 0); | 385 RTC_DCHECK_GT(play_buffer_.size(), 0); |
386 #ifdef AUDIO_DEVICE_PLAYS_SINUS_TONE | 386 #ifdef AUDIO_DEVICE_PLAYS_SINUS_TONE |
387 const double phase_increment = | 387 const double phase_increment = |
388 k2Pi * 440.0 / static_cast<double>(play_sample_rate_); | 388 k2Pi * 440.0 / static_cast<double>(play_sample_rate_); |
389 int16_t* destination_r = reinterpret_cast<int16_t*>(audio_buffer); | 389 int16_t* destination_r = reinterpret_cast<int16_t*>(audio_buffer); |
390 for (size_t i = 0; i < play_buffer_.size(); ++i) { | 390 for (size_t i = 0; i < play_buffer_.size(); ++i) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 RTC_DCHECK_RUN_ON(&playout_thread_checker_); | 505 RTC_DCHECK_RUN_ON(&playout_thread_checker_); |
506 rtc::CritScope cs(&lock_); | 506 rtc::CritScope cs(&lock_); |
507 ++stats_.play_callbacks; | 507 ++stats_.play_callbacks; |
508 stats_.play_samples += samples_per_channel; | 508 stats_.play_samples += samples_per_channel; |
509 if (max_abs > stats_.max_play_level) { | 509 if (max_abs > stats_.max_play_level) { |
510 stats_.max_play_level = max_abs; | 510 stats_.max_play_level = max_abs; |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 } // namespace webrtc | 514 } // namespace webrtc |
OLD | NEW |