| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/webrtc_audio_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 int frames_per_10_ms = (sample_rate / 100); | 83 int frames_per_10_ms = (sample_rate / 100); |
| 84 int bytes_per_sample = sizeof(render_buffer_[0]); | 84 int bytes_per_sample = sizeof(render_buffer_[0]); |
| 85 const int bytes_per_10_ms = | 85 const int bytes_per_10_ms = |
| 86 audio_bus->channels() * frames_per_10_ms * bytes_per_sample; | 86 audio_bus->channels() * frames_per_10_ms * bytes_per_sample; |
| 87 DCHECK_EQ(audio_bus->frames() % frames_per_10_ms, 0); | 87 DCHECK_EQ(audio_bus->frames() % frames_per_10_ms, 0); |
| 88 | 88 |
| 89 // Get audio frames in blocks of 10 milliseconds from the registered | 89 // Get audio frames in blocks of 10 milliseconds from the registered |
| 90 // webrtc::AudioTransport source. Keep reading until our internal buffer | 90 // webrtc::AudioTransport source. Keep reading until our internal buffer |
| 91 // is full. | 91 // is full. |
| 92 int accumulated_audio_frames = 0; | 92 int accumulated_audio_frames = 0; |
| 93 int16* audio_data = &render_buffer_[0]; | 93 int16_t* audio_data = &render_buffer_[0]; |
| 94 while (accumulated_audio_frames < audio_bus->frames()) { | 94 while (accumulated_audio_frames < audio_bus->frames()) { |
| 95 // Get 10ms and append output to temporary byte buffer. | 95 // Get 10ms and append output to temporary byte buffer. |
| 96 int64_t elapsed_time_ms = -1; | 96 int64_t elapsed_time_ms = -1; |
| 97 int64_t ntp_time_ms = -1; | 97 int64_t ntp_time_ms = -1; |
| 98 static const int kBitsPerByte = 8; | 98 static const int kBitsPerByte = 8; |
| 99 audio_transport_callback_->PullRenderData(bytes_per_sample * kBitsPerByte, | 99 audio_transport_callback_->PullRenderData(bytes_per_sample * kBitsPerByte, |
| 100 sample_rate, | 100 sample_rate, |
| 101 audio_bus->channels(), | 101 audio_bus->channels(), |
| 102 frames_per_10_ms, | 102 frames_per_10_ms, |
| 103 audio_data, | 103 audio_data, |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 // If there is no capturer or there are more than one open capture devices, | 509 // If there is no capturer or there are more than one open capture devices, |
| 510 // return false. | 510 // return false. |
| 511 if (capturers_.size() != 1) | 511 if (capturers_.size() != 1) |
| 512 return false; | 512 return false; |
| 513 | 513 |
| 514 return capturers_.back()->GetPairedOutputParameters( | 514 return capturers_.back()->GetPairedOutputParameters( |
| 515 session_id, output_sample_rate, output_frames_per_buffer); | 515 session_id, output_sample_rate, output_frames_per_buffer); |
| 516 } | 516 } |
| 517 | 517 |
| 518 } // namespace content | 518 } // namespace content |
| OLD | NEW |