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

Side by Side Diff: ppapi/proxy/ppb_audio_proxy.cc

Issue 1154613006: Update pepper to not assume that SharedMemoryHandle is an int. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from piman. Created 5 years, 6 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
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 "ppapi/proxy/ppb_audio_proxy.h" 5 #include "ppapi/proxy/ppb_audio_proxy.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/threading/simple_thread.h" 8 #include "base/threading/simple_thread.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_audio.h" 10 #include "ppapi/c/ppb_audio.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Resource overrides. 43 // Resource overrides.
44 PPB_Audio_API* AsPPB_Audio_API() override; 44 PPB_Audio_API* AsPPB_Audio_API() override;
45 45
46 // PPB_Audio_API implementation. 46 // PPB_Audio_API implementation.
47 PP_Resource GetCurrentConfig() override; 47 PP_Resource GetCurrentConfig() override;
48 PP_Bool StartPlayback() override; 48 PP_Bool StartPlayback() override;
49 PP_Bool StopPlayback() override; 49 PP_Bool StopPlayback() override;
50 int32_t Open(PP_Resource config_id, 50 int32_t Open(PP_Resource config_id,
51 scoped_refptr<TrackedCallback> create_callback) override; 51 scoped_refptr<TrackedCallback> create_callback) override;
52 int32_t GetSyncSocket(int* sync_socket) override; 52 int32_t GetSyncSocket(int* sync_socket) override;
53 int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) override; 53 int32_t GetSharedMemory(base::SharedMemory* shm, uint32_t* shm_size) override;
54 54
55 private: 55 private:
56 // Owning reference to the current config object. This isn't actually used, 56 // Owning reference to the current config object. This isn't actually used,
57 // we just dish it out as requested by the plugin. 57 // we just dish it out as requested by the plugin.
58 PP_Resource config_; 58 PP_Resource config_;
59 59
60 DISALLOW_COPY_AND_ASSIGN(Audio); 60 DISALLOW_COPY_AND_ASSIGN(Audio);
61 }; 61 };
62 62
63 Audio::Audio(const HostResource& audio_id, 63 Audio::Audio(const HostResource& audio_id,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 int32_t Audio::Open(PP_Resource config_id, 116 int32_t Audio::Open(PP_Resource config_id,
117 scoped_refptr<TrackedCallback> create_callback) { 117 scoped_refptr<TrackedCallback> create_callback) {
118 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. 118 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
119 } 119 }
120 120
121 int32_t Audio::GetSyncSocket(int* sync_socket) { 121 int32_t Audio::GetSyncSocket(int* sync_socket) {
122 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. 122 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
123 } 123 }
124 124
125 int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) { 125 int32_t Audio::GetSharedMemory(base::SharedMemory* shm, uint32_t* shm_size) {
126 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. 126 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
127 } 127 }
128 128
129 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher) 129 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher)
130 : InterfaceProxy(dispatcher), 130 : InterfaceProxy(dispatcher),
131 callback_factory_(this) { 131 callback_factory_(this) {
132 } 132 }
133 133
134 PPB_Audio_Proxy::~PPB_Audio_Proxy() { 134 PPB_Audio_Proxy::~PPB_Audio_Proxy() {
135 } 135 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 enter.object()->StartPlayback(); 239 enter.object()->StartPlayback();
240 else 240 else
241 enter.object()->StopPlayback(); 241 enter.object()->StopPlayback();
242 } 242 }
243 243
244 void PPB_Audio_Proxy::AudioChannelConnected( 244 void PPB_Audio_Proxy::AudioChannelConnected(
245 int32_t result, 245 int32_t result,
246 const HostResource& resource) { 246 const HostResource& resource) {
247 IPC::PlatformFileForTransit socket_handle = 247 IPC::PlatformFileForTransit socket_handle =
248 IPC::InvalidPlatformFileForTransit(); 248 IPC::InvalidPlatformFileForTransit();
249 base::SharedMemoryHandle shared_memory = IPC::InvalidPlatformFileForTransit(); 249 base::SharedMemoryHandle shared_memory = base::SharedMemory::NULLHandle();
250 uint32_t audio_buffer_length = 0; 250 uint32_t audio_buffer_length = 0;
251 251
252 int32_t result_code = result; 252 int32_t result_code = result;
253 if (result_code == PP_OK) { 253 if (result_code == PP_OK) {
254 result_code = GetAudioConnectedHandles(resource, &socket_handle, 254 result_code = GetAudioConnectedHandles(resource, &socket_handle,
255 &shared_memory, 255 &shared_memory,
256 &audio_buffer_length); 256 &audio_buffer_length);
257 } 257 }
258 258
259 // Send all the values, even on error. This simplifies some of our cleanup 259 // Send all the values, even on error. This simplifies some of our cleanup
(...skipping 23 matching lines...) Expand all
283 if (result != PP_OK) 283 if (result != PP_OK)
284 return result; 284 return result;
285 285
286 // socket_handle doesn't belong to us: don't close it. 286 // socket_handle doesn't belong to us: don't close it.
287 *foreign_socket_handle = dispatcher()->ShareHandleWithRemote( 287 *foreign_socket_handle = dispatcher()->ShareHandleWithRemote(
288 IntToPlatformFile(socket_handle), false); 288 IntToPlatformFile(socket_handle), false);
289 if (*foreign_socket_handle == IPC::InvalidPlatformFileForTransit()) 289 if (*foreign_socket_handle == IPC::InvalidPlatformFileForTransit())
290 return PP_ERROR_FAILED; 290 return PP_ERROR_FAILED;
291 291
292 // Get the shared memory for the buffer. 292 // Get the shared memory for the buffer.
293 int shared_memory_handle; 293 base::SharedMemory shared_memory;
294 result = enter.object()->GetSharedMemory(&shared_memory_handle, 294 result =
295 shared_memory_length); 295 enter.object()->GetSharedMemory(&shared_memory, shared_memory_length);
296 if (result != PP_OK) 296 if (result != PP_OK)
297 return result; 297 return result;
298 298
299 // shared_memory_handle doesn't belong to us: don't close it. 299 // shared_memory_handle doesn't belong to us: don't close it.
300 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( 300 *foreign_shared_memory_handle =
301 IntToPlatformFile(shared_memory_handle), false); 301 dispatcher()->ShareSharedMemoryHandleWithRemote(shared_memory.handle());
302 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) 302 if (!base::SharedMemory::IsHandleValid(*foreign_shared_memory_handle))
303 return PP_ERROR_FAILED; 303 return PP_ERROR_FAILED;
304 304
305 return PP_OK; 305 return PP_OK;
306 } 306 }
307 #endif // !defined(OS_NACL) 307 #endif // !defined(OS_NACL)
308 308
309 // Processed in the plugin (message from host). 309 // Processed in the plugin (message from host).
310 void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated( 310 void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated(
311 const HostResource& audio_id, 311 const HostResource& audio_id,
312 int32_t result_code, 312 int32_t result_code,
(...skipping 15 matching lines...) Expand all
328 static_cast<Audio*>(enter.object())->SetStreamInfo( 328 static_cast<Audio*>(enter.object())->SetStreamInfo(
329 enter.resource()->pp_instance(), handle.shmem(), handle.size(), 329 enter.resource()->pp_instance(), handle.shmem(), handle.size(),
330 IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()), 330 IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()),
331 config.object()->GetSampleRate(), 331 config.object()->GetSampleRate(),
332 config.object()->GetSampleFrameCount()); 332 config.object()->GetSampleFrameCount());
333 } 333 }
334 } 334 }
335 335
336 } // namespace proxy 336 } // namespace proxy
337 } // namespace ppapi 337 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698