| 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "content/common/child_process.h" | 8 #include "content/common/child_process.h" |
| 9 #include "content/common/media/audio_messages.h" | 9 #include "content/common/media/audio_messages.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // Convert the number of pending bytes in the render buffer | 196 // Convert the number of pending bytes in the render buffer |
| 197 // into milliseconds. | 197 // into milliseconds. |
| 198 audio_delay_milliseconds_ = pending_data / bytes_per_ms; | 198 audio_delay_milliseconds_ = pending_data / bytes_per_ms; |
| 199 | 199 |
| 200 FireRenderCallback(); | 200 FireRenderCallback(); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 void AudioDevice::FireRenderCallback() { | 204 void AudioDevice::FireRenderCallback() { |
| 205 if (callback_) { | 205 if (callback_) { |
| 206 // printf("AudioDevice::FireRenderCallback!!!!!!!!!!!!!! : %d\n", (int)buffer_si
ze_); |
| 206 // Update the audio-delay measurement then ask client to render audio. | 207 // Update the audio-delay measurement then ask client to render audio. |
| 207 callback_->Render(audio_data_, buffer_size_, audio_delay_milliseconds_); | 208 callback_->Render(audio_data_, buffer_size_, audio_delay_milliseconds_); |
| 208 | 209 |
| 209 // Interleave, scale, and clip to int16. | 210 // Interleave, scale, and clip to int16. |
| 210 int16* output_buffer16 = static_cast<int16*>(shared_memory_data()); | 211 int16* output_buffer16 = static_cast<int16*>(shared_memory_data()); |
| 211 media::InterleaveFloatToInt16(audio_data_, output_buffer16, buffer_size_); | 212 media::InterleaveFloatToInt16(audio_data_, output_buffer16, buffer_size_); |
| 212 } | 213 } |
| 213 } | 214 } |
| 214 | 215 |
| 215 double AudioDevice::GetAudioHardwareSampleRate() { | 216 double AudioDevice::GetAudioHardwareSampleRate() { |
| 216 // Uses cached value if possible. | 217 // Uses cached value if possible. |
| 217 static double hardware_sample_rate = 0; | 218 static double hardware_sample_rate = 0; |
| 218 if (!hardware_sample_rate) { | 219 if (!hardware_sample_rate) { |
| 219 RenderThread::current()->Send( | 220 RenderThread::current()->Send( |
| 220 new ViewHostMsg_GetHardwareSampleRate(&hardware_sample_rate)); | 221 new ViewHostMsg_GetHardwareSampleRate(&hardware_sample_rate)); |
| 221 } | 222 } |
| 222 return hardware_sample_rate; | 223 return hardware_sample_rate; |
| 223 } | 224 } |
| OLD | NEW |