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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Map internal volume range of [0.0, 1.0] into [0, 255] used by the | 94 // Map internal volume range of [0.0, 1.0] into [0, 255] used by the |
95 // webrtc::VoiceEngine. | 95 // webrtc::VoiceEngine. |
96 microphone_volume_ = static_cast<uint32_t>(volume * kMaxVolumeLevel); | 96 microphone_volume_ = static_cast<uint32_t>(volume * kMaxVolumeLevel); |
97 } | 97 } |
98 | 98 |
99 const int channels = number_of_channels; | 99 const int channels = number_of_channels; |
100 DCHECK_LE(channels, input_channels()); | 100 DCHECK_LE(channels, input_channels()); |
101 uint32_t new_mic_level = 0; | 101 uint32_t new_mic_level = 0; |
102 | 102 |
103 int samples_per_sec = input_sample_rate(); | 103 int samples_per_sec = input_sample_rate(); |
104 if (samples_per_sec == 44100) { | |
105 // Even if the hardware runs at 44.1kHz, we use 44.0 internally. | |
106 samples_per_sec = 44000; | |
107 } | |
108 const int samples_per_10_msec = (samples_per_sec / 100); | 104 const int samples_per_10_msec = (samples_per_sec / 100); |
109 int bytes_per_sample = input_audio_parameters.bits_per_sample() / 8; | 105 int bytes_per_sample = input_audio_parameters.bits_per_sample() / 8; |
110 const int bytes_per_10_msec = | 106 const int bytes_per_10_msec = |
111 channels * samples_per_10_msec * bytes_per_sample; | 107 channels * samples_per_10_msec * bytes_per_sample; |
112 int accumulated_audio_samples = 0; | 108 int accumulated_audio_samples = 0; |
113 | 109 |
114 const uint8* audio_byte_buffer = reinterpret_cast<const uint8*>(audio_data); | 110 const uint8* audio_byte_buffer = reinterpret_cast<const uint8*>(audio_data); |
115 | 111 |
116 // Write audio samples in blocks of 10 milliseconds to the registered | 112 // Write audio samples in blocks of 10 milliseconds to the registered |
117 // webrtc::AudioTransport sink. Keep writing until our internal byte | 113 // webrtc::AudioTransport sink. Keep writing until our internal byte |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 { | 160 { |
165 base::AutoLock auto_lock(lock_); | 161 base::AutoLock auto_lock(lock_); |
166 // Store the reported audio delay locally. | 162 // Store the reported audio delay locally. |
167 output_delay_ms_ = audio_delay_milliseconds; | 163 output_delay_ms_ = audio_delay_milliseconds; |
168 } | 164 } |
169 | 165 |
170 const int channels = number_of_channels; | 166 const int channels = number_of_channels; |
171 DCHECK_LE(channels, output_channels()); | 167 DCHECK_LE(channels, output_channels()); |
172 | 168 |
173 int samples_per_sec = output_sample_rate(); | 169 int samples_per_sec = output_sample_rate(); |
174 if (samples_per_sec == 44100) { | |
175 // Even if the hardware runs at 44.1kHz, we use 44.0 internally. | |
176 samples_per_sec = 44000; | |
177 } | |
178 int samples_per_10_msec = (samples_per_sec / 100); | 170 int samples_per_10_msec = (samples_per_sec / 100); |
179 int bytes_per_sample = output_audio_parameters_.bits_per_sample() / 8; | 171 int bytes_per_sample = output_audio_parameters_.bits_per_sample() / 8; |
180 const int bytes_per_10_msec = | 172 const int bytes_per_10_msec = |
181 channels * samples_per_10_msec * bytes_per_sample; | 173 channels * samples_per_10_msec * bytes_per_sample; |
182 | 174 |
183 uint32_t num_audio_samples = 0; | 175 uint32_t num_audio_samples = 0; |
184 int accumulated_audio_samples = 0; | 176 int accumulated_audio_samples = 0; |
185 | 177 |
186 // Get audio samples in blocks of 10 milliseconds from the registered | 178 // Get audio samples in blocks of 10 milliseconds from the registered |
187 // webrtc::AudioTransport source. Keep reading until our internal buffer | 179 // webrtc::AudioTransport source. Keep reading until our internal buffer |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 return false; | 491 return false; |
500 | 492 |
501 if (!renderer->Initialize(this)) | 493 if (!renderer->Initialize(this)) |
502 return false; | 494 return false; |
503 | 495 |
504 renderer_ = renderer; | 496 renderer_ = renderer; |
505 return true; | 497 return true; |
506 } | 498 } |
507 | 499 |
508 } // namespace content | 500 } // namespace content |
OLD | NEW |