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

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: Another nits pass. 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,
54 uint32_t* shm_size) override;
54 55
55 private: 56 private:
56 // Owning reference to the current config object. This isn't actually used, 57 // Owning reference to the current config object. This isn't actually used,
57 // we just dish it out as requested by the plugin. 58 // we just dish it out as requested by the plugin.
58 PP_Resource config_; 59 PP_Resource config_;
59 60
60 DISALLOW_COPY_AND_ASSIGN(Audio); 61 DISALLOW_COPY_AND_ASSIGN(Audio);
61 }; 62 };
62 63
63 Audio::Audio(const HostResource& audio_id, 64 Audio::Audio(const HostResource& audio_id,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 116
116 int32_t Audio::Open(PP_Resource config_id, 117 int32_t Audio::Open(PP_Resource config_id,
117 scoped_refptr<TrackedCallback> create_callback) { 118 scoped_refptr<TrackedCallback> create_callback) {
118 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. 119 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
119 } 120 }
120 121
121 int32_t Audio::GetSyncSocket(int* sync_socket) { 122 int32_t Audio::GetSyncSocket(int* sync_socket) {
122 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. 123 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
123 } 124 }
124 125
125 int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) { 126 int32_t Audio::GetSharedMemory(base::SharedMemory** shm, uint32_t* shm_size) {
126 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. 127 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
127 } 128 }
128 129
129 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher) 130 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher)
130 : InterfaceProxy(dispatcher), 131 : InterfaceProxy(dispatcher),
131 callback_factory_(this) { 132 callback_factory_(this) {
132 } 133 }
133 134
134 PPB_Audio_Proxy::~PPB_Audio_Proxy() { 135 PPB_Audio_Proxy::~PPB_Audio_Proxy() {
135 } 136 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 enter.object()->StartPlayback(); 240 enter.object()->StartPlayback();
240 else 241 else
241 enter.object()->StopPlayback(); 242 enter.object()->StopPlayback();
242 } 243 }
243 244
244 void PPB_Audio_Proxy::AudioChannelConnected( 245 void PPB_Audio_Proxy::AudioChannelConnected(
245 int32_t result, 246 int32_t result,
246 const HostResource& resource) { 247 const HostResource& resource) {
247 IPC::PlatformFileForTransit socket_handle = 248 IPC::PlatformFileForTransit socket_handle =
248 IPC::InvalidPlatformFileForTransit(); 249 IPC::InvalidPlatformFileForTransit();
249 base::SharedMemoryHandle shared_memory = IPC::InvalidPlatformFileForTransit(); 250 base::SharedMemoryHandle shared_memory = base::SharedMemory::NULLHandle();
250 uint32_t audio_buffer_length = 0; 251 uint32_t audio_buffer_length = 0;
251 252
252 int32_t result_code = result; 253 int32_t result_code = result;
253 if (result_code == PP_OK) { 254 if (result_code == PP_OK) {
254 result_code = GetAudioConnectedHandles(resource, &socket_handle, 255 result_code = GetAudioConnectedHandles(resource, &socket_handle,
255 &shared_memory, 256 &shared_memory,
256 &audio_buffer_length); 257 &audio_buffer_length);
257 } 258 }
258 259
259 // Send all the values, even on error. This simplifies some of our cleanup 260 // Send all the values, even on error. This simplifies some of our cleanup
(...skipping 23 matching lines...) Expand all
283 if (result != PP_OK) 284 if (result != PP_OK)
284 return result; 285 return result;
285 286
286 // socket_handle doesn't belong to us: don't close it. 287 // socket_handle doesn't belong to us: don't close it.
287 *foreign_socket_handle = dispatcher()->ShareHandleWithRemote( 288 *foreign_socket_handle = dispatcher()->ShareHandleWithRemote(
288 IntToPlatformFile(socket_handle), false); 289 IntToPlatformFile(socket_handle), false);
289 if (*foreign_socket_handle == IPC::InvalidPlatformFileForTransit()) 290 if (*foreign_socket_handle == IPC::InvalidPlatformFileForTransit())
290 return PP_ERROR_FAILED; 291 return PP_ERROR_FAILED;
291 292
292 // Get the shared memory for the buffer. 293 // Get the shared memory for the buffer.
293 int shared_memory_handle; 294 base::SharedMemory* shared_memory;
294 result = enter.object()->GetSharedMemory(&shared_memory_handle, 295 result =
295 shared_memory_length); 296 enter.object()->GetSharedMemory(&shared_memory, shared_memory_length);
296 if (result != PP_OK) 297 if (result != PP_OK)
297 return result; 298 return result;
298 299
299 // shared_memory_handle doesn't belong to us: don't close it. 300 // shared_memory_handle doesn't belong to us: don't close it.
300 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( 301 *foreign_shared_memory_handle =
301 IntToPlatformFile(shared_memory_handle), false); 302 dispatcher()->ShareSharedMemoryHandleWithRemote(shared_memory->handle());
302 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) 303 if (!base::SharedMemory::IsHandleValid(*foreign_shared_memory_handle))
303 return PP_ERROR_FAILED; 304 return PP_ERROR_FAILED;
304 305
305 return PP_OK; 306 return PP_OK;
306 } 307 }
307 #endif // !defined(OS_NACL) 308 #endif // !defined(OS_NACL)
308 309
309 // Processed in the plugin (message from host). 310 // Processed in the plugin (message from host).
310 void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated( 311 void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated(
311 const HostResource& audio_id, 312 const HostResource& audio_id,
312 int32_t result_code, 313 int32_t result_code,
(...skipping 15 matching lines...) Expand all
328 static_cast<Audio*>(enter.object())->SetStreamInfo( 329 static_cast<Audio*>(enter.object())->SetStreamInfo(
329 enter.resource()->pp_instance(), handle.shmem(), handle.size(), 330 enter.resource()->pp_instance(), handle.shmem(), handle.size(),
330 IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()), 331 IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()),
331 config.object()->GetSampleRate(), 332 config.object()->GetSampleRate(),
332 config.object()->GetSampleFrameCount()); 333 config.object()->GetSampleFrameCount());
333 } 334 }
334 } 335 }
335 336
336 } // namespace proxy 337 } // namespace proxy
337 } // namespace ppapi 338 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698