OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 27 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
28 #include "content/common/media/audio_messages.h" | 28 #include "content/common/media/audio_messages.h" |
29 #include "content/common/pepper_file_messages.h" | 29 #include "content/common/pepper_file_messages.h" |
30 #include "content/common/pepper_plugin_registry.h" | 30 #include "content/common/pepper_plugin_registry.h" |
31 #include "content/common/pepper_messages.h" | 31 #include "content/common/pepper_messages.h" |
32 #include "content/common/quota_dispatcher.h" | 32 #include "content/common/quota_dispatcher.h" |
33 #include "content/common/view_messages.h" | 33 #include "content/common/view_messages.h" |
34 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
35 #include "content/public/renderer/content_renderer_client.h" | 35 #include "content/public/renderer/content_renderer_client.h" |
36 #include "content/renderer/gamepad_shared_memory_reader.h" | 36 #include "content/renderer/gamepad_shared_memory_reader.h" |
| 37 #include "content/renderer/media/audio_hardware.h" |
37 #include "content/renderer/media/audio_input_message_filter.h" | 38 #include "content/renderer/media/audio_input_message_filter.h" |
38 #include "content/renderer/media/audio_message_filter.h" | 39 #include "content/renderer/media/audio_message_filter.h" |
39 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" | 40 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" |
40 #include "content/renderer/media/video_capture_impl_manager.h" | 41 #include "content/renderer/media/video_capture_impl_manager.h" |
41 #include "content/renderer/p2p/p2p_transport_impl.h" | 42 #include "content/renderer/p2p/p2p_transport_impl.h" |
42 #include "content/renderer/pepper_platform_context_3d_impl.h" | 43 #include "content/renderer/pepper_platform_context_3d_impl.h" |
43 #include "content/renderer/render_thread_impl.h" | 44 #include "content/renderer/render_thread_impl.h" |
44 #include "content/renderer/render_view_impl.h" | 45 #include "content/renderer/render_view_impl.h" |
45 #include "content/renderer/render_widget_fullscreen_pepper.h" | 46 #include "content/renderer/render_widget_fullscreen_pepper.h" |
46 #include "content/renderer/webplugin_delegate_proxy.h" | 47 #include "content/renderer/webplugin_delegate_proxy.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 uint32_t sample_rate, uint32_t sample_count, | 222 uint32_t sample_rate, uint32_t sample_count, |
222 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) { | 223 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) { |
223 | 224 |
224 DCHECK(client); | 225 DCHECK(client); |
225 // Make sure we don't call init more than once. | 226 // Make sure we don't call init more than once. |
226 DCHECK_EQ(0, stream_id_); | 227 DCHECK_EQ(0, stream_id_); |
227 | 228 |
228 client_ = client; | 229 client_ = client; |
229 | 230 |
230 AudioParameters params; | 231 AudioParameters params; |
231 params.format = AudioParameters::AUDIO_PCM_LINEAR; | 232 // Use the low latency back end if the client request is compatible. |
| 233 if (sample_rate == audio_hardware::GetOutputSampleRate() && |
| 234 sample_count % audio_hardware::GetOutputBufferSize() == 0) |
| 235 params.format = AudioParameters::AUDIO_PCM_LOW_LATENCY; |
| 236 else |
| 237 params.format = AudioParameters::AUDIO_PCM_LINEAR; |
232 params.channels = 2; | 238 params.channels = 2; |
233 params.sample_rate = sample_rate; | 239 params.sample_rate = sample_rate; |
234 params.bits_per_sample = 16; | 240 params.bits_per_sample = 16; |
235 params.samples_per_packet = sample_count; | 241 params.samples_per_packet = sample_count; |
236 | 242 |
237 ChildProcess::current()->io_message_loop()->PostTask( | 243 ChildProcess::current()->io_message_loop()->PostTask( |
238 FROM_HERE, | 244 FROM_HERE, |
239 base::Bind(&PlatformAudioImpl::InitializeOnIOThread, this, params)); | 245 base::Bind(&PlatformAudioImpl::InitializeOnIOThread, this, params)); |
240 return true; | 246 return true; |
241 } | 247 } |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 bool final_result) { | 1260 bool final_result) { |
1255 render_view_->reportFindInPageMatchCount(identifier, total, final_result); | 1261 render_view_->reportFindInPageMatchCount(identifier, total, final_result); |
1256 } | 1262 } |
1257 | 1263 |
1258 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier, | 1264 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier, |
1259 int index) { | 1265 int index) { |
1260 render_view_->reportFindInPageSelection( | 1266 render_view_->reportFindInPageSelection( |
1261 identifier, index + 1, WebKit::WebRect()); | 1267 identifier, index + 1, WebKit::WebRect()); |
1262 } | 1268 } |
1263 | 1269 |
| 1270 uint32_t PepperPluginDelegateImpl::AudioHardwareOutputSampleRate() { |
| 1271 return static_cast<uint32_t>(audio_hardware::GetOutputSampleRate()); |
| 1272 } |
| 1273 |
| 1274 uint32_t PepperPluginDelegateImpl::AudioHardwareOutputBufferSize() { |
| 1275 return static_cast<uint32_t>(audio_hardware::GetOutputBufferSize()); |
| 1276 } |
| 1277 |
1264 webkit::ppapi::PluginDelegate::PlatformAudio* | 1278 webkit::ppapi::PluginDelegate::PlatformAudio* |
1265 PepperPluginDelegateImpl::CreateAudio( | 1279 PepperPluginDelegateImpl::CreateAudio( |
1266 uint32_t sample_rate, | 1280 uint32_t sample_rate, |
1267 uint32_t sample_count, | 1281 uint32_t sample_count, |
1268 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) { | 1282 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) { |
1269 scoped_refptr<PlatformAudioImpl> audio(new PlatformAudioImpl()); | 1283 scoped_refptr<PlatformAudioImpl> audio(new PlatformAudioImpl()); |
1270 if (audio->Initialize(sample_rate, sample_count, client)) { | 1284 if (audio->Initialize(sample_rate, sample_count, client)) { |
1271 // Balanced by Release invoked in PlatformAudioImpl::ShutDownOnIOThread(). | 1285 // Balanced by Release invoked in PlatformAudioImpl::ShutDownOnIOThread(). |
1272 return audio.release(); | 1286 return audio.release(); |
1273 } else { | 1287 } else { |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( | 2120 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( |
2107 webkit::ppapi::PluginInstance* instance) { | 2121 webkit::ppapi::PluginInstance* instance) { |
2108 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); | 2122 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); |
2109 if (it != mouse_lock_instances_.end()) { | 2123 if (it != mouse_lock_instances_.end()) { |
2110 MouseLockDispatcher::LockTarget* target = it->second; | 2124 MouseLockDispatcher::LockTarget* target = it->second; |
2111 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); | 2125 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); |
2112 delete target; | 2126 delete target; |
2113 mouse_lock_instances_.erase(it); | 2127 mouse_lock_instances_.erase(it); |
2114 } | 2128 } |
2115 } | 2129 } |
OLD | NEW |