| 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 "ppapi/proxy/ppb_audio_proxy.h" | 5 #include "ppapi/proxy/ppb_audio_proxy.h" |
| 6 | 6 |
| 7 #include "base/threading/simple_thread.h" | 7 #include "base/threading/simple_thread.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/c/ppb_audio.h" | 9 #include "ppapi/c/ppb_audio.h" |
| 10 #include "ppapi/c/trusted/ppb_audio_trusted.h" | 10 #include "ppapi/c/trusted/ppb_audio_trusted.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 PP_Resource Create(PP_Instance instance_id, | 66 PP_Resource Create(PP_Instance instance_id, |
| 67 PP_Resource config_id, | 67 PP_Resource config_id, |
| 68 PPB_Audio_Callback callback, | 68 PPB_Audio_Callback callback, |
| 69 void* user_data) { | 69 void* user_data) { |
| 70 PluginResource* config = PluginResourceTracker::GetInstance()-> | 70 PluginResource* config = PluginResourceTracker::GetInstance()-> |
| 71 GetResourceObject(config_id); | 71 GetResourceObject(config_id); |
| 72 if (!config) | 72 if (!config) |
| 73 return 0; | 73 return 0; |
| 74 | 74 |
| 75 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
| 76 if (!dispatcher) |
| 77 return 0; |
| 78 |
| 75 HostResource result; | 79 HostResource result; |
| 76 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBAudio_Create( | 80 dispatcher->Send(new PpapiHostMsg_PPBAudio_Create( |
| 77 INTERFACE_ID_PPB_AUDIO, instance_id, config->host_resource(), &result)); | 81 INTERFACE_ID_PPB_AUDIO, instance_id, config->host_resource(), &result)); |
| 78 if (result.is_null()) | 82 if (result.is_null()) |
| 79 return 0; | 83 return 0; |
| 80 | 84 |
| 81 linked_ptr<Audio> object(new Audio(result, config_id, callback, user_data)); | 85 linked_ptr<Audio> object(new Audio(result, config_id, callback, user_data)); |
| 82 return PluginResourceTracker::GetInstance()->AddResource(object); | 86 return PluginResourceTracker::GetInstance()->AddResource(object); |
| 83 } | 87 } |
| 84 | 88 |
| 85 PP_Bool IsAudio(PP_Resource resource) { | 89 PP_Bool IsAudio(PP_Resource resource) { |
| 86 Audio* object = PluginResource::GetAs<Audio>(resource); | 90 Audio* object = PluginResource::GetAs<Audio>(resource); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 113 } | 117 } |
| 114 | 118 |
| 115 const PPB_Audio audio_interface = { | 119 const PPB_Audio audio_interface = { |
| 116 &Create, | 120 &Create, |
| 117 &IsAudio, | 121 &IsAudio, |
| 118 &GetCurrentConfiguration, | 122 &GetCurrentConfiguration, |
| 119 &StartPlayback, | 123 &StartPlayback, |
| 120 &StopPlayback | 124 &StopPlayback |
| 121 }; | 125 }; |
| 122 | 126 |
| 127 InterfaceProxy* CreateAudioProxy(Dispatcher* dispatcher, |
| 128 const void* target_interface) { |
| 129 return new PPB_Audio_Proxy(dispatcher, target_interface); |
| 130 } |
| 131 |
| 123 } // namespace | 132 } // namespace |
| 124 | 133 |
| 125 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher, | 134 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher, |
| 126 const void* target_interface) | 135 const void* target_interface) |
| 127 : InterfaceProxy(dispatcher, target_interface), | 136 : InterfaceProxy(dispatcher, target_interface), |
| 128 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 137 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 129 } | 138 } |
| 130 | 139 |
| 131 PPB_Audio_Proxy::~PPB_Audio_Proxy() { | 140 PPB_Audio_Proxy::~PPB_Audio_Proxy() { |
| 132 } | 141 } |
| 133 | 142 |
| 134 const void* PPB_Audio_Proxy::GetSourceInterface() const { | 143 // static |
| 135 return &audio_interface; | 144 const InterfaceProxy::Info* PPB_Audio_Proxy::GetInfo() { |
| 136 } | 145 static const Info info = { |
| 137 | 146 &audio_interface, |
| 138 InterfaceID PPB_Audio_Proxy::GetInterfaceId() const { | 147 PPB_AUDIO_INTERFACE, |
| 139 return INTERFACE_ID_PPB_AUDIO; | 148 INTERFACE_ID_PPB_AUDIO, |
| 149 false, |
| 150 &CreateAudioProxy, |
| 151 }; |
| 152 return &info; |
| 140 } | 153 } |
| 141 | 154 |
| 142 bool PPB_Audio_Proxy::OnMessageReceived(const IPC::Message& msg) { | 155 bool PPB_Audio_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 143 bool handled = true; | 156 bool handled = true; |
| 144 IPC_BEGIN_MESSAGE_MAP(PPB_Audio_Proxy, msg) | 157 IPC_BEGIN_MESSAGE_MAP(PPB_Audio_Proxy, msg) |
| 145 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudio_Create, OnMsgCreate) | 158 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudio_Create, OnMsgCreate) |
| 146 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudio_StartOrStop, | 159 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudio_StartOrStop, |
| 147 OnMsgStartOrStop) | 160 OnMsgStartOrStop) |
| 148 IPC_MESSAGE_HANDLER(PpapiMsg_PPBAudio_NotifyAudioStreamCreated, | 161 IPC_MESSAGE_HANDLER(PpapiMsg_PPBAudio_NotifyAudioStreamCreated, |
| 149 OnMsgNotifyAudioStreamCreated) | 162 OnMsgNotifyAudioStreamCreated) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // close the source handle. | 307 // close the source handle. |
| 295 if (!shared_memory.GiveToProcess(dispatcher()->remote_process_handle(), | 308 if (!shared_memory.GiveToProcess(dispatcher()->remote_process_handle(), |
| 296 foreign_shared_memory_handle)) | 309 foreign_shared_memory_handle)) |
| 297 return PP_ERROR_FAILED; | 310 return PP_ERROR_FAILED; |
| 298 | 311 |
| 299 return PP_OK; | 312 return PP_OK; |
| 300 } | 313 } |
| 301 | 314 |
| 302 } // namespace proxy | 315 } // namespace proxy |
| 303 } // namespace pp | 316 } // namespace pp |
| OLD | NEW |