OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dev/ppb_audio_dev.h" | |
9 #include "ppapi/c/dev/ppb_audio_trusted_dev.h" | |
10 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/c/ppb_audio.h" |
| 10 #include "ppapi/c/trusted/ppb_audio_trusted.h" |
11 #include "ppapi/proxy/interface_id.h" | 11 #include "ppapi/proxy/interface_id.h" |
12 #include "ppapi/proxy/plugin_dispatcher.h" | 12 #include "ppapi/proxy/plugin_dispatcher.h" |
13 #include "ppapi/proxy/plugin_resource.h" | 13 #include "ppapi/proxy/plugin_resource.h" |
14 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
15 #include "ppapi/shared_impl/audio_impl.h" | 15 #include "ppapi/shared_impl/audio_impl.h" |
16 | 16 |
17 namespace pp { | 17 namespace pp { |
18 namespace proxy { | 18 namespace proxy { |
19 | 19 |
20 class Audio : public PluginResource, public pp::shared_impl::AudioImpl { | 20 class Audio : public PluginResource, public pp::shared_impl::AudioImpl { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 PP_Bool StopPlayback(PP_Resource audio_id) { | 100 PP_Bool StopPlayback(PP_Resource audio_id) { |
101 Audio* object = PluginResource::GetAs<Audio>(audio_id); | 101 Audio* object = PluginResource::GetAs<Audio>(audio_id); |
102 if (!object) | 102 if (!object) |
103 return PP_FALSE; | 103 return PP_FALSE; |
104 object->StopPlayback(audio_id); | 104 object->StopPlayback(audio_id); |
105 return PP_TRUE; | 105 return PP_TRUE; |
106 } | 106 } |
107 | 107 |
108 const PPB_Audio_Dev audio_interface = { | 108 const PPB_Audio audio_interface = { |
109 &Create, | 109 &Create, |
110 &IsAudio, | 110 &IsAudio, |
111 &GetCurrentConfiguration, | 111 &GetCurrentConfiguration, |
112 &StartPlayback, | 112 &StartPlayback, |
113 &StopPlayback | 113 &StopPlayback |
114 }; | 114 }; |
115 | 115 |
116 } // namespace | 116 } // namespace |
117 | 117 |
118 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher, | 118 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher, |
(...skipping 22 matching lines...) Expand all Loading... |
141 IPC_MESSAGE_HANDLER(PpapiMsg_PPBAudio_NotifyAudioStreamCreated, | 141 IPC_MESSAGE_HANDLER(PpapiMsg_PPBAudio_NotifyAudioStreamCreated, |
142 OnMsgNotifyAudioStreamCreated) | 142 OnMsgNotifyAudioStreamCreated) |
143 IPC_MESSAGE_UNHANDLED(handled = false) | 143 IPC_MESSAGE_UNHANDLED(handled = false) |
144 IPC_END_MESSAGE_MAP() | 144 IPC_END_MESSAGE_MAP() |
145 return handled; | 145 return handled; |
146 } | 146 } |
147 | 147 |
148 void PPB_Audio_Proxy::OnMsgCreate(PP_Instance instance_id, | 148 void PPB_Audio_Proxy::OnMsgCreate(PP_Instance instance_id, |
149 PP_Resource config_id, | 149 PP_Resource config_id, |
150 PP_Resource* result) { | 150 PP_Resource* result) { |
151 const PPB_AudioTrusted_Dev* audio_trusted = | 151 const PPB_AudioTrusted* audio_trusted = |
152 reinterpret_cast<const PPB_AudioTrusted_Dev*>( | 152 reinterpret_cast<const PPB_AudioTrusted*>( |
153 dispatcher()->GetLocalInterface(PPB_AUDIO_TRUSTED_DEV_INTERFACE)); | 153 dispatcher()->GetLocalInterface(PPB_AUDIO_TRUSTED_INTERFACE)); |
154 if (!audio_trusted) { | 154 if (!audio_trusted) { |
155 *result = 0; | 155 *result = 0; |
156 return; | 156 return; |
157 } | 157 } |
158 | 158 |
159 *result = audio_trusted->CreateTrusted(instance_id); | 159 *result = audio_trusted->CreateTrusted(instance_id); |
160 if (!result) | 160 if (!result) |
161 return; | 161 return; |
162 | 162 |
163 CompletionCallback callback = callback_factory_.NewCallback( | 163 CompletionCallback callback = callback_factory_.NewCallback( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 INTERFACE_ID_PPB_AUDIO, resource, result_code, socket_handle, | 224 INTERFACE_ID_PPB_AUDIO, resource, result_code, socket_handle, |
225 shared_memory, shared_memory_length)); | 225 shared_memory, shared_memory_length)); |
226 } | 226 } |
227 | 227 |
228 int32_t PPB_Audio_Proxy::GetAudioConnectedHandles( | 228 int32_t PPB_Audio_Proxy::GetAudioConnectedHandles( |
229 PP_Resource resource, | 229 PP_Resource resource, |
230 IPC::PlatformFileForTransit* foreign_socket_handle, | 230 IPC::PlatformFileForTransit* foreign_socket_handle, |
231 base::SharedMemoryHandle* foreign_shared_memory_handle, | 231 base::SharedMemoryHandle* foreign_shared_memory_handle, |
232 uint32_t* shared_memory_length) { | 232 uint32_t* shared_memory_length) { |
233 // Get the trusted audio interface which will give us the handles. | 233 // Get the trusted audio interface which will give us the handles. |
234 const PPB_AudioTrusted_Dev* audio_trusted = | 234 const PPB_AudioTrusted* audio_trusted = |
235 reinterpret_cast<const PPB_AudioTrusted_Dev*>( | 235 reinterpret_cast<const PPB_AudioTrusted*>( |
236 dispatcher()->GetLocalInterface(PPB_AUDIO_TRUSTED_DEV_INTERFACE)); | 236 dispatcher()->GetLocalInterface(PPB_AUDIO_TRUSTED_INTERFACE)); |
237 if (!audio_trusted) | 237 if (!audio_trusted) |
238 return PP_ERROR_NOINTERFACE; | 238 return PP_ERROR_NOINTERFACE; |
239 | 239 |
240 // Get the socket handle for signaling. | 240 // Get the socket handle for signaling. |
241 int32_t socket_handle; | 241 int32_t socket_handle; |
242 int32_t result = audio_trusted->GetSyncSocket(resource, &socket_handle); | 242 int32_t result = audio_trusted->GetSyncSocket(resource, &socket_handle); |
243 if (result != PP_OK) | 243 if (result != PP_OK) |
244 return result; | 244 return result; |
245 | 245 |
246 #if defined(OS_WIN) | 246 #if defined(OS_WIN) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // close the source handle. | 278 // close the source handle. |
279 if (!shared_memory.GiveToProcess(dispatcher()->remote_process_handle(), | 279 if (!shared_memory.GiveToProcess(dispatcher()->remote_process_handle(), |
280 foreign_shared_memory_handle)) | 280 foreign_shared_memory_handle)) |
281 return PP_ERROR_FAILED; | 281 return PP_ERROR_FAILED; |
282 | 282 |
283 return PP_OK; | 283 return PP_OK; |
284 } | 284 } |
285 | 285 |
286 } // namespace proxy | 286 } // namespace proxy |
287 } // namespace pp | 287 } // namespace pp |
OLD | NEW |