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

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

Issue 10837064: Corresponding change in Pepper since EnumerateDevices contract is changed. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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_input_proxy.h" 5 #include "ppapi/proxy/ppb_audio_input_proxy.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "ppapi/c/dev/ppb_audio_input_dev.h" 8 #include "ppapi/c/dev/ppb_audio_input_dev.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_audio_config.h" 10 #include "ppapi/c/ppb_audio_config.h"
(...skipping 28 matching lines...) Expand all
39 scoped_refptr<TrackedCallback> create_callback) OVERRIDE; 39 scoped_refptr<TrackedCallback> create_callback) OVERRIDE;
40 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; 40 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE;
41 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; 41 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE;
42 virtual const std::vector<DeviceRefData>& GetDeviceRefData() const OVERRIDE; 42 virtual const std::vector<DeviceRefData>& GetDeviceRefData() const OVERRIDE;
43 43
44 private: 44 private:
45 // PPB_AudioInput_Shared implementation. 45 // PPB_AudioInput_Shared implementation.
46 virtual int32_t InternalEnumerateDevices( 46 virtual int32_t InternalEnumerateDevices(
47 PP_Resource* devices, 47 PP_Resource* devices,
48 scoped_refptr<TrackedCallback> callback) OVERRIDE; 48 scoped_refptr<TrackedCallback> callback) OVERRIDE;
49 virtual int32_t InternalStopEnumerateDevices(PP_Resource* devices) OVERRIDE;
49 virtual int32_t InternalOpen( 50 virtual int32_t InternalOpen(
50 const std::string& device_id, 51 const std::string& device_id,
51 PP_AudioSampleRate sample_rate, 52 PP_AudioSampleRate sample_rate,
52 uint32_t sample_frame_count, 53 uint32_t sample_frame_count,
53 scoped_refptr<TrackedCallback> callback) OVERRIDE; 54 scoped_refptr<TrackedCallback> callback) OVERRIDE;
54 virtual PP_Bool InternalStartCapture() OVERRIDE; 55 virtual PP_Bool InternalStartCapture() OVERRIDE;
55 virtual PP_Bool InternalStopCapture() OVERRIDE; 56 virtual PP_Bool InternalStopCapture() OVERRIDE;
56 virtual void InternalClose() OVERRIDE; 57 virtual void InternalClose() OVERRIDE;
57 58
58 PluginDispatcher* GetDispatcher() const { 59 PluginDispatcher* GetDispatcher() const {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 int32_t AudioInput::InternalEnumerateDevices( 95 int32_t AudioInput::InternalEnumerateDevices(
95 PP_Resource* devices, 96 PP_Resource* devices,
96 scoped_refptr<TrackedCallback> callback) { 97 scoped_refptr<TrackedCallback> callback) {
97 devices_ = devices; 98 devices_ = devices;
98 enumerate_devices_callback_ = callback; 99 enumerate_devices_callback_ = callback;
99 GetDispatcher()->Send(new PpapiHostMsg_PPBAudioInput_EnumerateDevices( 100 GetDispatcher()->Send(new PpapiHostMsg_PPBAudioInput_EnumerateDevices(
100 API_ID_PPB_AUDIO_INPUT_DEV, host_resource())); 101 API_ID_PPB_AUDIO_INPUT_DEV, host_resource()));
101 return PP_OK_COMPLETIONPENDING; 102 return PP_OK_COMPLETIONPENDING;
102 } 103 }
103 104
105 int32_t AudioInput::InternalStopEnumerateDevices(PP_Resource* devices) {
106 if (devices_ == devices) {
107 GetDispatcher()->Send(new PpapiHostMsg_PPBAudioInput_EnumerateDevices(
108 API_ID_PPB_AUDIO_INPUT_DEV, host_resource()));
109 }
110 return PP_OK;
111 }
112
104 int32_t AudioInput::InternalOpen(const std::string& device_id, 113 int32_t AudioInput::InternalOpen(const std::string& device_id,
105 PP_AudioSampleRate sample_rate, 114 PP_AudioSampleRate sample_rate,
106 uint32_t sample_frame_count, 115 uint32_t sample_frame_count,
107 scoped_refptr<TrackedCallback> callback) { 116 scoped_refptr<TrackedCallback> callback) {
108 open_callback_ = callback; 117 open_callback_ = callback;
109 GetDispatcher()->Send(new PpapiHostMsg_PPBAudioInput_Open( 118 GetDispatcher()->Send(new PpapiHostMsg_PPBAudioInput_Open(
110 API_ID_PPB_AUDIO_INPUT_DEV, host_resource(), device_id, sample_rate, 119 API_ID_PPB_AUDIO_INPUT_DEV, host_resource(), device_id, sample_rate,
111 sample_frame_count)); 120 sample_frame_count));
112 return PP_OK_COMPLETIONPENDING; 121 return PP_OK_COMPLETIONPENDING;
113 } 122 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 189
181 return (new AudioInput(result))->GetReference(); 190 return (new AudioInput(result))->GetReference();
182 } 191 }
183 192
184 bool PPB_AudioInput_Proxy::OnMessageReceived(const IPC::Message& msg) { 193 bool PPB_AudioInput_Proxy::OnMessageReceived(const IPC::Message& msg) {
185 bool handled = true; 194 bool handled = true;
186 IPC_BEGIN_MESSAGE_MAP(PPB_AudioInput_Proxy, msg) 195 IPC_BEGIN_MESSAGE_MAP(PPB_AudioInput_Proxy, msg)
187 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_Create, OnMsgCreate) 196 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_Create, OnMsgCreate)
188 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_EnumerateDevices, 197 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_EnumerateDevices,
189 OnMsgEnumerateDevices) 198 OnMsgEnumerateDevices)
199 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_StopEnumerateDevices,
200 OnMsgStopEnumerateDevices)
190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_Open, OnMsgOpen) 201 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_Open, OnMsgOpen)
191 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_StartOrStop, 202 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_StartOrStop,
192 OnMsgStartOrStop) 203 OnMsgStartOrStop)
193 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_Close, OnMsgClose) 204 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioInput_Close, OnMsgClose)
194 205
195 IPC_MESSAGE_HANDLER(PpapiMsg_PPBAudioInput_EnumerateDevicesACK, 206 IPC_MESSAGE_HANDLER(PpapiMsg_PPBAudioInput_EnumerateDevicesACK,
196 OnMsgEnumerateDevicesACK) 207 OnMsgEnumerateDevicesACK)
197 IPC_MESSAGE_HANDLER(PpapiMsg_PPBAudioInput_OpenACK, OnMsgOpenACK) 208 IPC_MESSAGE_HANDLER(PpapiMsg_PPBAudioInput_OpenACK, OnMsgOpenACK)
198 IPC_MESSAGE_UNHANDLED(handled = false) 209 IPC_MESSAGE_UNHANDLED(handled = false)
199 IPC_END_MESSAGE_MAP() 210 IPC_END_MESSAGE_MAP()
(...skipping 14 matching lines...) Expand all
214 void PPB_AudioInput_Proxy::OnMsgEnumerateDevices( 225 void PPB_AudioInput_Proxy::OnMsgEnumerateDevices(
215 const ppapi::HostResource& audio_input) { 226 const ppapi::HostResource& audio_input) {
216 EnterHostFromHostResourceForceCallback<PPB_AudioInput_API> enter( 227 EnterHostFromHostResourceForceCallback<PPB_AudioInput_API> enter(
217 audio_input, callback_factory_, 228 audio_input, callback_factory_,
218 &PPB_AudioInput_Proxy::EnumerateDevicesACKInHost, audio_input); 229 &PPB_AudioInput_Proxy::EnumerateDevicesACKInHost, audio_input);
219 230
220 if (enter.succeeded()) 231 if (enter.succeeded())
221 enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback())); 232 enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback()));
222 } 233 }
223 234
235 void PPB_AudioInput_Proxy::OnMsgStopEnumerateDevices(
236 const ppapi::HostResource& audio_input) {
237 EnterHostFromHostResource<PPB_AudioInput_API> enter(audio_input);
238 if (enter.succeeded())
239 enter.object()->StopEnumerateDevices(NULL);
240 }
241
224 void PPB_AudioInput_Proxy::OnMsgOpen(const ppapi::HostResource& audio_input, 242 void PPB_AudioInput_Proxy::OnMsgOpen(const ppapi::HostResource& audio_input,
225 const std::string& device_id, 243 const std::string& device_id,
226 int32_t sample_rate, 244 int32_t sample_rate,
227 uint32_t sample_frame_count) { 245 uint32_t sample_frame_count) {
228 // The ...ForceCallback class will help ensure the callback is always called. 246 // The ...ForceCallback class will help ensure the callback is always called.
229 // All error cases must call SetResult on this class. 247 // All error cases must call SetResult on this class.
230 EnterHostFromHostResourceForceCallback<PPB_AudioInput_API> enter( 248 EnterHostFromHostResourceForceCallback<PPB_AudioInput_API> enter(
231 audio_input, callback_factory_, &PPB_AudioInput_Proxy::OpenACKInHost, 249 audio_input, callback_factory_, &PPB_AudioInput_Proxy::OpenACKInHost,
232 audio_input); 250 audio_input);
233 if (enter.failed()) 251 if (enter.failed())
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( 388 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote(
371 IntToPlatformFile(shared_memory_handle), false); 389 IntToPlatformFile(shared_memory_handle), false);
372 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) 390 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit())
373 return PP_ERROR_FAILED; 391 return PP_ERROR_FAILED;
374 392
375 return PP_OK; 393 return PP_OK;
376 } 394 }
377 395
378 } // namespace proxy 396 } // namespace proxy
379 } // namespace ppapi 397 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698