Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: content/renderer/pepper_plugin_delegate_impl.cc

Issue 9129007: Work on improving PpbAudioConfig:RecommendSampleFrameCount (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "content/common/media/audio_messages.h" 27 #include "content/common/media/audio_messages.h"
28 #include "content/common/pepper_file_messages.h" 28 #include "content/common/pepper_file_messages.h"
29 #include "content/common/pepper_plugin_registry.h" 29 #include "content/common/pepper_plugin_registry.h"
30 #include "content/common/pepper_messages.h" 30 #include "content/common/pepper_messages.h"
31 #include "content/common/quota_dispatcher.h" 31 #include "content/common/quota_dispatcher.h"
32 #include "content/common/view_messages.h" 32 #include "content/common/view_messages.h"
33 #include "content/public/common/content_switches.h" 33 #include "content/public/common/content_switches.h"
34 #include "content/public/common/context_menu_params.h" 34 #include "content/public/common/context_menu_params.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/media_stream_dispatcher.h" 40 #include "content/renderer/media/media_stream_dispatcher.h"
40 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" 41 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
41 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" 42 #include "content/renderer/media/pepper_platform_video_decoder_impl.h"
42 #include "content/renderer/p2p/p2p_transport_impl.h" 43 #include "content/renderer/p2p/p2p_transport_impl.h"
43 #include "content/renderer/pepper_platform_context_3d_impl.h" 44 #include "content/renderer/pepper_platform_context_3d_impl.h"
44 #include "content/renderer/pepper_platform_video_capture_impl.h" 45 #include "content/renderer/pepper_platform_video_capture_impl.h"
45 #include "content/renderer/render_thread_impl.h" 46 #include "content/renderer/render_thread_impl.h"
46 #include "content/renderer/render_view_impl.h" 47 #include "content/renderer/render_view_impl.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 int32 stream_id_; 216 int32 stream_id_;
216 217
217 base::MessageLoopProxy* main_message_loop_proxy_; 218 base::MessageLoopProxy* main_message_loop_proxy_;
218 219
219 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl); 220 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl);
220 }; 221 };
221 222
222 bool PlatformAudioImpl::Initialize( 223 bool PlatformAudioImpl::Initialize(
223 uint32_t sample_rate, uint32_t sample_count, 224 uint32_t sample_rate, uint32_t sample_count,
224 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) { 225 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) {
225
226 DCHECK(client); 226 DCHECK(client);
227 // Make sure we don't call init more than once. 227 // Make sure we don't call init more than once.
228 DCHECK_EQ(0, stream_id_); 228 DCHECK_EQ(0, stream_id_);
229 229
230 client_ = client; 230 client_ = client;
231 231
232 AudioParameters params; 232 AudioParameters params;
233 params.format = AudioParameters::AUDIO_PCM_LINEAR; 233 const uint32_t kMaxSampleCountForLowLatency = 2048;
234 // Use the low latency back end if the client request is compatible, and
235 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY.
236 if (sample_rate == audio_hardware::GetOutputSampleRate() &&
237 sample_count <= kMaxSampleCountForLowLatency &&
238 sample_count % audio_hardware::GetOutputBufferSize() == 0)
239 params.format = AudioParameters::AUDIO_PCM_LOW_LATENCY;
240 else
241 params.format = AudioParameters::AUDIO_PCM_LINEAR;
234 params.channels = 2; 242 params.channels = 2;
235 params.sample_rate = sample_rate; 243 params.sample_rate = sample_rate;
236 params.bits_per_sample = 16; 244 params.bits_per_sample = 16;
237 params.samples_per_packet = sample_count; 245 params.samples_per_packet = sample_count;
238 246
239 ChildProcess::current()->io_message_loop()->PostTask( 247 ChildProcess::current()->io_message_loop()->PostTask(
240 FROM_HERE, 248 FROM_HERE,
241 base::Bind(&PlatformAudioImpl::InitializeOnIOThread, this, params)); 249 base::Bind(&PlatformAudioImpl::InitializeOnIOThread, this, params));
242 return true; 250 return true;
243 } 251 }
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 bool final_result) { 1359 bool final_result) {
1352 render_view_->reportFindInPageMatchCount(identifier, total, final_result); 1360 render_view_->reportFindInPageMatchCount(identifier, total, final_result);
1353 } 1361 }
1354 1362
1355 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier, 1363 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier,
1356 int index) { 1364 int index) {
1357 render_view_->reportFindInPageSelection( 1365 render_view_->reportFindInPageSelection(
1358 identifier, index + 1, WebKit::WebRect()); 1366 identifier, index + 1, WebKit::WebRect());
1359 } 1367 }
1360 1368
1369 uint32_t PepperPluginDelegateImpl::GetAudioHardwareOutputSampleRate() {
1370 return static_cast<uint32_t>(audio_hardware::GetOutputSampleRate());
1371 }
1372
1373 uint32_t PepperPluginDelegateImpl::GetAudioHardwareOutputBufferSize() {
1374 return static_cast<uint32_t>(audio_hardware::GetOutputBufferSize());
1375 }
1376
1361 webkit::ppapi::PluginDelegate::PlatformAudio* 1377 webkit::ppapi::PluginDelegate::PlatformAudio*
1362 PepperPluginDelegateImpl::CreateAudio( 1378 PepperPluginDelegateImpl::CreateAudio(
1363 uint32_t sample_rate, 1379 uint32_t sample_rate,
1364 uint32_t sample_count, 1380 uint32_t sample_count,
1365 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) { 1381 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) {
1366 scoped_refptr<PlatformAudioImpl> audio(new PlatformAudioImpl()); 1382 scoped_refptr<PlatformAudioImpl> audio(new PlatformAudioImpl());
1367 if (audio->Initialize(sample_rate, sample_count, client)) { 1383 if (audio->Initialize(sample_rate, sample_count, client)) {
1368 // Balanced by Release invoked in PlatformAudioImpl::ShutDownOnIOThread(). 1384 // Balanced by Release invoked in PlatformAudioImpl::ShutDownOnIOThread().
1369 return audio.release(); 1385 return audio.release();
1370 } else { 1386 } else {
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( 2248 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter(
2233 webkit::ppapi::PluginInstance* instance) { 2249 webkit::ppapi::PluginInstance* instance) {
2234 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); 2250 LockTargetMap::iterator it = mouse_lock_instances_.find(instance);
2235 if (it != mouse_lock_instances_.end()) { 2251 if (it != mouse_lock_instances_.end()) {
2236 MouseLockDispatcher::LockTarget* target = it->second; 2252 MouseLockDispatcher::LockTarget* target = it->second;
2237 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); 2253 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target);
2238 delete target; 2254 delete target;
2239 mouse_lock_instances_.erase(it); 2255 mouse_lock_instances_.erase(it);
2240 } 2256 }
2241 } 2257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698