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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 LOG(FATAL) << "Should never get OnRequestPacket in PlatformAudioImpl"; | 200 LOG(FATAL) << "Should never get OnRequestPacket in PlatformAudioImpl"; |
201 } | 201 } |
202 | 202 |
203 virtual void OnStateChanged(AudioStreamState state) OVERRIDE {} | 203 virtual void OnStateChanged(AudioStreamState state) OVERRIDE {} |
204 | 204 |
205 virtual void OnCreated(base::SharedMemoryHandle handle, | 205 virtual void OnCreated(base::SharedMemoryHandle handle, |
206 uint32 length) OVERRIDE { | 206 uint32 length) OVERRIDE { |
207 LOG(FATAL) << "Should never get OnCreated in PlatformAudioImpl"; | 207 LOG(FATAL) << "Should never get OnCreated in PlatformAudioImpl"; |
208 } | 208 } |
209 | 209 |
210 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 210 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
211 base::SyncSocket::Handle socket_handle, | 211 base::SyncSocket::Handle socket_handle, |
212 uint32 length) OVERRIDE; | 212 uint32 length) OVERRIDE; |
213 | 213 |
214 virtual void OnVolume(double volume) OVERRIDE {} | 214 virtual void OnVolume(double volume) OVERRIDE {} |
215 | 215 |
216 // The client to notify when the stream is created. THIS MUST ONLY BE | 216 // The client to notify when the stream is created. THIS MUST ONLY BE |
217 // ACCESSED ON THE MAIN THREAD. | 217 // ACCESSED ON THE MAIN THREAD. |
218 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client_; | 218 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client_; |
219 | 219 |
220 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE | 220 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE |
221 // I/O thread except to send messages and get the message loop. | 221 // I/O thread except to send messages and get the message loop. |
222 scoped_refptr<AudioMessageFilter> filter_; | 222 scoped_refptr<AudioMessageFilter> filter_; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Called on the main thread to stop all audio callbacks. We must only change | 277 // Called on the main thread to stop all audio callbacks. We must only change |
278 // the client on the main thread, and the delegates from the I/O thread. | 278 // the client on the main thread, and the delegates from the I/O thread. |
279 client_ = NULL; | 279 client_ = NULL; |
280 ChildProcess::current()->io_message_loop()->PostTask( | 280 ChildProcess::current()->io_message_loop()->PostTask( |
281 FROM_HERE, | 281 FROM_HERE, |
282 base::Bind(&PlatformAudioImpl::ShutDownOnIOThread, this)); | 282 base::Bind(&PlatformAudioImpl::ShutDownOnIOThread, this)); |
283 } | 283 } |
284 | 284 |
285 void PlatformAudioImpl::InitializeOnIOThread(const AudioParameters& params) { | 285 void PlatformAudioImpl::InitializeOnIOThread(const AudioParameters& params) { |
286 stream_id_ = filter_->AddDelegate(this); | 286 stream_id_ = filter_->AddDelegate(this); |
287 filter_->Send(new AudioHostMsg_CreateStream(stream_id_, params, true)); | 287 filter_->Send(new AudioHostMsg_CreateStream(stream_id_, params)); |
288 } | 288 } |
289 | 289 |
290 void PlatformAudioImpl::StartPlaybackOnIOThread() { | 290 void PlatformAudioImpl::StartPlaybackOnIOThread() { |
291 if (stream_id_) | 291 if (stream_id_) |
292 filter_->Send(new AudioHostMsg_PlayStream(stream_id_)); | 292 filter_->Send(new AudioHostMsg_PlayStream(stream_id_)); |
293 } | 293 } |
294 | 294 |
295 void PlatformAudioImpl::StopPlaybackOnIOThread() { | 295 void PlatformAudioImpl::StopPlaybackOnIOThread() { |
296 if (stream_id_) | 296 if (stream_id_) |
297 filter_->Send(new AudioHostMsg_PauseStream(stream_id_)); | 297 filter_->Send(new AudioHostMsg_PauseStream(stream_id_)); |
298 } | 298 } |
299 | 299 |
300 void PlatformAudioImpl::ShutDownOnIOThread() { | 300 void PlatformAudioImpl::ShutDownOnIOThread() { |
301 // Make sure we don't call shutdown more than once. | 301 // Make sure we don't call shutdown more than once. |
302 if (!stream_id_) | 302 if (!stream_id_) |
303 return; | 303 return; |
304 | 304 |
305 filter_->Send(new AudioHostMsg_CloseStream(stream_id_)); | 305 filter_->Send(new AudioHostMsg_CloseStream(stream_id_)); |
306 filter_->RemoveDelegate(stream_id_); | 306 filter_->RemoveDelegate(stream_id_); |
307 stream_id_ = 0; | 307 stream_id_ = 0; |
308 | 308 |
309 Release(); // Release for the delegate, balances out the reference taken in | 309 Release(); // Release for the delegate, balances out the reference taken in |
310 // PepperPluginDelegateImpl::CreateAudio. | 310 // PepperPluginDelegateImpl::CreateAudio. |
311 } | 311 } |
312 | 312 |
313 void PlatformAudioImpl::OnLowLatencyCreated( | 313 void PlatformAudioImpl::OnStreamCreated( |
314 base::SharedMemoryHandle handle, base::SyncSocket::Handle socket_handle, | 314 base::SharedMemoryHandle handle, base::SyncSocket::Handle socket_handle, |
315 uint32 length) { | 315 uint32 length) { |
316 #if defined(OS_WIN) | 316 #if defined(OS_WIN) |
317 DCHECK(handle); | 317 DCHECK(handle); |
318 DCHECK(socket_handle); | 318 DCHECK(socket_handle); |
319 #else | 319 #else |
320 DCHECK_NE(-1, handle.fd); | 320 DCHECK_NE(-1, handle.fd); |
321 DCHECK_NE(-1, socket_handle); | 321 DCHECK_NE(-1, socket_handle); |
322 #endif | 322 #endif |
323 DCHECK(length); | 323 DCHECK(length); |
324 | 324 |
325 if (base::MessageLoopProxy::current() == main_message_loop_proxy_) { | 325 if (base::MessageLoopProxy::current() == main_message_loop_proxy_) { |
326 // Must dereference the client only on the main thread. Shutdown may have | 326 // Must dereference the client only on the main thread. Shutdown may have |
327 // occurred while the request was in-flight, so we need to NULL check. | 327 // occurred while the request was in-flight, so we need to NULL check. |
328 if (client_) | 328 if (client_) |
329 client_->StreamCreated(handle, length, socket_handle); | 329 client_->StreamCreated(handle, length, socket_handle); |
330 } else { | 330 } else { |
331 main_message_loop_proxy_->PostTask(FROM_HERE, | 331 main_message_loop_proxy_->PostTask(FROM_HERE, |
332 base::Bind(&PlatformAudioImpl::OnLowLatencyCreated, this, handle, | 332 base::Bind(&PlatformAudioImpl::OnStreamCreated, this, handle, |
333 socket_handle, length)); | 333 socket_handle, length)); |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 class PlatformAudioInputImpl | 337 class PlatformAudioInputImpl |
338 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, | 338 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, |
339 public AudioInputMessageFilter::Delegate, | 339 public AudioInputMessageFilter::Delegate, |
340 public base::RefCountedThreadSafe<PlatformAudioInputImpl> { | 340 public base::RefCountedThreadSafe<PlatformAudioInputImpl> { |
341 public: | 341 public: |
342 PlatformAudioInputImpl() | 342 PlatformAudioInputImpl() |
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( | 2108 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( |
2109 webkit::ppapi::PluginInstance* instance) { | 2109 webkit::ppapi::PluginInstance* instance) { |
2110 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); | 2110 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); |
2111 if (it != mouse_lock_instances_.end()) { | 2111 if (it != mouse_lock_instances_.end()) { |
2112 MouseLockDispatcher::LockTarget* target = it->second; | 2112 MouseLockDispatcher::LockTarget* target = it->second; |
2113 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); | 2113 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); |
2114 delete target; | 2114 delete target; |
2115 mouse_lock_instances_.erase(it); | 2115 mouse_lock_instances_.erase(it); |
2116 } | 2116 } |
2117 } | 2117 } |
OLD | NEW |