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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 only_silence_recorded_ = false; | 315 only_silence_recorded_ = false; |
316 } | 316 } |
317 } | 317 } |
318 // Update recording stats which is used as base for periodic logging of the | 318 // Update recording stats which is used as base for periodic logging of the |
319 // audio input state. | 319 // audio input state. |
320 UpdateRecStats(max_abs, samples_per_channel); | 320 UpdateRecStats(max_abs, samples_per_channel); |
321 return 0; | 321 return 0; |
322 } | 322 } |
323 | 323 |
324 int32_t AudioDeviceBuffer::DeliverRecordedData() { | 324 int32_t AudioDeviceBuffer::DeliverRecordedData() { |
325 int64_t start_time = rtc::TimeMicros(); | |
325 RTC_DCHECK_RUN_ON(&recording_thread_checker_); | 326 RTC_DCHECK_RUN_ON(&recording_thread_checker_); |
326 if (!audio_transport_cb_) { | 327 if (!audio_transport_cb_) { |
327 LOG(LS_WARNING) << "Invalid audio transport"; | 328 LOG(LS_WARNING) << "Invalid audio transport"; |
328 return 0; | 329 return 0; |
329 } | 330 } |
330 const size_t frames = rec_buffer_.size() / rec_channels_; | 331 const size_t frames = rec_buffer_.size() / rec_channels_; |
331 const size_t bytes_per_frame = rec_channels_ * sizeof(int16_t); | 332 const size_t bytes_per_frame = rec_channels_ * sizeof(int16_t); |
332 uint32_t new_mic_level(0); | 333 uint32_t new_mic_level(0); |
333 uint32_t total_delay_ms = play_delay_ms_ + rec_delay_ms_; | 334 uint32_t total_delay_ms = play_delay_ms_ + rec_delay_ms_; |
334 int32_t res = audio_transport_cb_->RecordedDataIsAvailable( | 335 int32_t res = audio_transport_cb_->RecordedDataIsAvailable( |
335 rec_buffer_.data(), frames, bytes_per_frame, rec_channels_, | 336 rec_buffer_.data(), frames, bytes_per_frame, rec_channels_, |
336 rec_sample_rate_, total_delay_ms, clock_drift_, current_mic_level_, | 337 rec_sample_rate_, total_delay_ms, clock_drift_, current_mic_level_, |
337 typing_status_, new_mic_level); | 338 typing_status_, new_mic_level); |
338 if (res != -1) { | 339 if (res != -1) { |
339 new_mic_level_ = new_mic_level; | 340 new_mic_level_ = new_mic_level; |
340 } else { | 341 } else { |
341 LOG(LS_ERROR) << "RecordedDataIsAvailable() failed"; | 342 LOG(LS_ERROR) << "RecordedDataIsAvailable() failed"; |
342 } | 343 } |
344 int64_t diff_time = rtc::TimeMicros() - start_time; | |
345 acc_diff_times_ += diff_time; | |
346 num_diff_times_++; | |
347 if (diff_time > max_diff_time_) { | |
348 max_diff_time_ = diff_time; | |
349 LOG(INFO) << "max_diff_time: " << max_diff_time_; | |
350 } | |
351 | |
343 return 0; | 352 return 0; |
344 } | 353 } |
345 | 354 |
346 int32_t AudioDeviceBuffer::RequestPlayoutData(size_t samples_per_channel) { | 355 int32_t AudioDeviceBuffer::RequestPlayoutData(size_t samples_per_channel) { |
347 RTC_DCHECK_RUN_ON(&playout_thread_checker_); | 356 RTC_DCHECK_RUN_ON(&playout_thread_checker_); |
348 // The consumer can change the requested size on the fly and we therefore | 357 // The consumer can change the requested size on the fly and we therefore |
349 // resize the buffer accordingly. Also takes place at the first call to this | 358 // resize the buffer accordingly. Also takes place at the first call to this |
350 // method. | 359 // method. |
351 const size_t total_samples = play_channels_ * samples_per_channel; | 360 const size_t total_samples = play_channels_ * samples_per_channel; |
352 if (play_buffer_.size() != total_samples) { | 361 if (play_buffer_.size() != total_samples) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 rate = diff_samples / (static_cast<float>(time_since_last) / 1000.0); | 467 rate = diff_samples / (static_cast<float>(time_since_last) / 1000.0); |
459 LOG(INFO) << "[PLAY: " << time_since_last << "msec, " | 468 LOG(INFO) << "[PLAY: " << time_since_last << "msec, " |
460 << play_sample_rate_ / 1000 << "kHz] callbacks: " | 469 << play_sample_rate_ / 1000 << "kHz] callbacks: " |
461 << stats.play_callbacks - last_stats_.play_callbacks << ", " | 470 << stats.play_callbacks - last_stats_.play_callbacks << ", " |
462 << "samples: " << diff_samples << ", " | 471 << "samples: " << diff_samples << ", " |
463 << "rate: " << static_cast<int>(rate + 0.5) << ", " | 472 << "rate: " << static_cast<int>(rate + 0.5) << ", " |
464 << "level: " << stats.max_play_level; | 473 << "level: " << stats.max_play_level; |
465 last_stats_ = stats; | 474 last_stats_ = stats; |
466 } | 475 } |
467 | 476 |
477 double avg_diff_time = (double)acc_diff_times_ / num_diff_times_; | |
478 LOG(INFO) << "avg_diff_time: " << avg_diff_time; | |
the sun
2017/03/23 12:45:55
log max here as well, to avoid it in audio cb
henrika_webrtc
2017/03/23 14:02:17
Done.
| |
479 | |
468 int64_t time_to_wait_ms = next_callback_time - rtc::TimeMillis(); | 480 int64_t time_to_wait_ms = next_callback_time - rtc::TimeMillis(); |
469 RTC_DCHECK_GT(time_to_wait_ms, 0) << "Invalid timer interval"; | 481 RTC_DCHECK_GT(time_to_wait_ms, 0) << "Invalid timer interval"; |
470 | 482 |
471 // Keep posting new (delayed) tasks until state is changed to kLogStop. | 483 // Keep posting new (delayed) tasks until state is changed to kLogStop. |
472 task_queue_.PostDelayedTask(rtc::Bind(&AudioDeviceBuffer::LogStats, this, | 484 task_queue_.PostDelayedTask(rtc::Bind(&AudioDeviceBuffer::LogStats, this, |
473 AudioDeviceBuffer::LOG_ACTIVE), | 485 AudioDeviceBuffer::LOG_ACTIVE), |
474 time_to_wait_ms); | 486 time_to_wait_ms); |
475 } | 487 } |
476 | 488 |
477 void AudioDeviceBuffer::ResetRecStats() { | 489 void AudioDeviceBuffer::ResetRecStats() { |
(...skipping 26 matching lines...) Expand all Loading... | |
504 RTC_DCHECK_RUN_ON(&playout_thread_checker_); | 516 RTC_DCHECK_RUN_ON(&playout_thread_checker_); |
505 rtc::CritScope cs(&lock_); | 517 rtc::CritScope cs(&lock_); |
506 ++stats_.play_callbacks; | 518 ++stats_.play_callbacks; |
507 stats_.play_samples += samples_per_channel; | 519 stats_.play_samples += samples_per_channel; |
508 if (max_abs > stats_.max_play_level) { | 520 if (max_abs > stats_.max_play_level) { |
509 stats_.max_play_level = max_abs; | 521 stats_.max_play_level = max_abs; |
510 } | 522 } |
511 } | 523 } |
512 | 524 |
513 } // namespace webrtc | 525 } // namespace webrtc |
OLD | NEW |