| OLD | NEW | 
|---|
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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/pepper_audio_output_host.h" | 5 #include "content/renderer/pepper/pepper_audio_output_host.h" | 
| 6 | 6 | 
| 7 #include "base/logging.h" | 7 #include "base/logging.h" | 
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" | 
| 9 #include "content/common/pepper_file_util.h" | 9 #include "content/common/pepper_file_util.h" | 
| 10 #include "content/renderer/pepper/pepper_audio_controller.h" | 10 #include "content/renderer/pepper/pepper_audio_controller.h" | 
| 11 #include "content/renderer/pepper/pepper_media_device_manager.h" | 11 #include "content/renderer/pepper/pepper_media_device_manager.h" | 
| 12 #include "content/renderer/pepper/pepper_platform_audio_output_dev.h" | 12 #include "content/renderer/pepper/pepper_platform_audio_output_dev.h" | 
| 13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 
| 14 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" | 14 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" | 
| 15 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 15 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 
| 16 #include "content/renderer/render_frame_impl.h" | 16 #include "content/renderer/render_frame_impl.h" | 
| 17 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" | 
| 18 #include "ppapi/c/pp_errors.h" | 18 #include "ppapi/c/pp_errors.h" | 
| 19 #include "ppapi/host/dispatch_host_message.h" | 19 #include "ppapi/host/dispatch_host_message.h" | 
| 20 #include "ppapi/host/ppapi_host.h" | 20 #include "ppapi/host/ppapi_host.h" | 
| 21 #include "ppapi/proxy/ppapi_messages.h" | 21 #include "ppapi/proxy/ppapi_messages.h" | 
| 22 #include "ppapi/proxy/serialized_structs.h" | 22 #include "ppapi/proxy/serialized_structs.h" | 
| 23 | 23 | 
| 24 namespace content { | 24 namespace content { | 
| 25 | 25 | 
| 26 namespace { |  | 
| 27 |  | 
| 28 base::PlatformFile ConvertSyncSocketHandle(const base::SyncSocket& socket) { |  | 
| 29   return socket.handle(); |  | 
| 30 } |  | 
| 31 |  | 
| 32 }  // namespace |  | 
| 33 |  | 
| 34 PepperAudioOutputHost::PepperAudioOutputHost(RendererPpapiHostImpl* host, | 26 PepperAudioOutputHost::PepperAudioOutputHost(RendererPpapiHostImpl* host, | 
| 35                                              PP_Instance instance, | 27                                              PP_Instance instance, | 
| 36                                              PP_Resource resource) | 28                                              PP_Resource resource) | 
| 37     : ResourceHost(host->GetPpapiHost(), instance, resource), | 29     : ResourceHost(host->GetPpapiHost(), instance, resource), | 
| 38       renderer_ppapi_host_(host), | 30       renderer_ppapi_host_(host), | 
| 39       audio_output_(NULL), | 31       audio_output_(NULL), | 
| 40       playback_throttled_(false), | 32       playback_throttled_(false), | 
| 41       enumeration_helper_(this, | 33       enumeration_helper_(this, | 
| 42                           PepperMediaDeviceManager::GetForRenderFrame( | 34                           PepperMediaDeviceManager::GetForRenderFrame( | 
| 43                               host->GetRenderFrameForInstance(pp_instance())), | 35                               host->GetRenderFrameForInstance(pp_instance())), | 
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 199   open_context_.params.AppendHandle(serialized_shared_memory_handle); | 191   open_context_.params.AppendHandle(serialized_shared_memory_handle); | 
| 200   SendOpenReply(result); | 192   SendOpenReply(result); | 
| 201 } | 193 } | 
| 202 | 194 | 
| 203 int32_t PepperAudioOutputHost::GetRemoteHandles( | 195 int32_t PepperAudioOutputHost::GetRemoteHandles( | 
| 204     const base::SyncSocket& socket, | 196     const base::SyncSocket& socket, | 
| 205     const base::SharedMemory& shared_memory, | 197     const base::SharedMemory& shared_memory, | 
| 206     IPC::PlatformFileForTransit* remote_socket_handle, | 198     IPC::PlatformFileForTransit* remote_socket_handle, | 
| 207     base::SharedMemoryHandle* remote_shared_memory_handle) { | 199     base::SharedMemoryHandle* remote_shared_memory_handle) { | 
| 208   *remote_socket_handle = renderer_ppapi_host_->ShareHandleWithRemote( | 200   *remote_socket_handle = renderer_ppapi_host_->ShareHandleWithRemote( | 
| 209       ConvertSyncSocketHandle(socket), false); | 201       socket.handle(), false); | 
| 210   if (*remote_socket_handle == IPC::InvalidPlatformFileForTransit()) | 202   if (*remote_socket_handle == IPC::InvalidPlatformFileForTransit()) | 
| 211     return PP_ERROR_FAILED; | 203     return PP_ERROR_FAILED; | 
| 212 | 204 | 
| 213   *remote_shared_memory_handle = | 205   *remote_shared_memory_handle = | 
| 214       renderer_ppapi_host_->ShareSharedMemoryHandleWithRemote( | 206       renderer_ppapi_host_->ShareSharedMemoryHandleWithRemote( | 
| 215           shared_memory.handle()); | 207           shared_memory.handle()); | 
| 216   if (!base::SharedMemory::IsHandleValid(*remote_shared_memory_handle)) | 208   if (!base::SharedMemory::IsHandleValid(*remote_shared_memory_handle)) | 
| 217     return PP_ERROR_FAILED; | 209     return PP_ERROR_FAILED; | 
| 218 | 210 | 
| 219   return PP_OK; | 211   return PP_OK; | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 256 | 248 | 
| 257   PepperPluginInstanceImpl* instance = static_cast<PepperPluginInstanceImpl*>( | 249   PepperPluginInstanceImpl* instance = static_cast<PepperPluginInstanceImpl*>( | 
| 258       PepperPluginInstance::Get(pp_instance())); | 250       PepperPluginInstance::Get(pp_instance())); | 
| 259   if (instance) | 251   if (instance) | 
| 260     instance->audio_controller().AddInstance(this); | 252     instance->audio_controller().AddInstance(this); | 
| 261 | 253 | 
| 262   audio_output_->StartPlayback(); | 254   audio_output_->StartPlayback(); | 
| 263 } | 255 } | 
| 264 | 256 | 
| 265 }  // namespace content | 257 }  // namespace content | 
| OLD | NEW | 
|---|