OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/audio_device.h" | 5 #include "content/renderer/media/audio_device.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 if (callback_) { | 226 if (callback_) { |
227 // Update the audio-delay measurement then ask client to render audio. | 227 // Update the audio-delay measurement then ask client to render audio. |
228 callback_->Render(audio_data_, buffer_size_, audio_delay_milliseconds_); | 228 callback_->Render(audio_data_, buffer_size_, audio_delay_milliseconds_); |
229 | 229 |
230 // Interleave, scale, and clip to int16. | 230 // Interleave, scale, and clip to int16. |
231 media::InterleaveFloatToInt16(audio_data_, | 231 media::InterleaveFloatToInt16(audio_data_, |
232 static_cast<int16*>(shared_memory_data()), | 232 static_cast<int16*>(shared_memory_data()), |
233 buffer_size_); | 233 buffer_size_); |
234 } | 234 } |
235 } | 235 } |
236 | |
237 double AudioDevice::GetAudioHardwareSampleRate() { | |
238 // Uses cached value if possible. | |
239 static double hardware_sample_rate = 0; | |
240 if (!hardware_sample_rate) { | |
241 RenderThreadImpl::current()->Send( | |
242 new ViewHostMsg_GetHardwareSampleRate(&hardware_sample_rate)); | |
243 } | |
244 return hardware_sample_rate; | |
245 } | |
246 | |
247 size_t AudioDevice::GetAudioHardwareBufferSize() { | |
248 // Uses cached value if possible. | |
249 static uint32 buffer_size = 0; | |
250 | |
251 if (!buffer_size) { | |
252 RenderThreadImpl::current()->Send( | |
253 new ViewHostMsg_GetHardwareBufferSize(&buffer_size)); | |
254 } | |
255 | |
256 return static_cast<size_t>(buffer_size); | |
257 } | |
OLD | NEW |