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

Side by Side Diff: ppapi/thunk/ppb_audio_input_thunk.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up for review. Created 8 years, 8 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/c/pp_errors.h" 5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/shared_impl/ppb_device_ref_shared.h" 6 #include "ppapi/shared_impl/ppb_device_ref_shared.h"
7 #include "ppapi/thunk/enter.h" 7 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/ppb_device_ref_api.h" 8 #include "ppapi/thunk/ppb_device_ref_api.h"
9 #include "ppapi/thunk/ppb_audio_input_api.h" 9 #include "ppapi/thunk/ppb_audio_input_api.h"
10 #include "ppapi/thunk/resource_creation_api.h" 10 #include "ppapi/thunk/resource_creation_api.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return PP_FromBool(enter.succeeded()); 42 return PP_FromBool(enter.succeeded());
43 } 43 }
44 44
45 int32_t EnumerateDevices(PP_Resource audio_input, 45 int32_t EnumerateDevices(PP_Resource audio_input,
46 PP_Resource* devices, 46 PP_Resource* devices,
47 PP_CompletionCallback callback) { 47 PP_CompletionCallback callback) {
48 EnterAudioInput enter(audio_input, callback, true); 48 EnterAudioInput enter(audio_input, callback, true);
49 if (enter.failed()) 49 if (enter.failed())
50 return enter.retval(); 50 return enter.retval();
51 51
52 return enter.SetResult(enter.object()->EnumerateDevices(devices, callback)); 52 return enter.SetResult(enter.object()->EnumerateDevices(devices,
53 enter.callback()));
53 } 54 }
54 55
55 int32_t Open(PP_Resource audio_input, 56 int32_t Open(PP_Resource audio_input,
56 PP_Resource device_ref, 57 PP_Resource device_ref,
57 PP_Resource config, 58 PP_Resource config,
58 PPB_AudioInput_Callback audio_input_callback, 59 PPB_AudioInput_Callback audio_input_callback,
59 void* user_data, 60 void* user_data,
60 PP_CompletionCallback callback) { 61 PP_CompletionCallback callback) {
61 EnterAudioInput enter(audio_input, callback, true); 62 EnterAudioInput enter(audio_input, callback, true);
62 if (enter.failed()) 63 if (enter.failed())
63 return enter.retval(); 64 return enter.retval();
64 65
65 std::string device_id; 66 std::string device_id;
66 // |device_id| remains empty if |device_ref| is 0, which means the default 67 // |device_id| remains empty if |device_ref| is 0, which means the default
67 // device. 68 // device.
68 if (device_ref != 0) { 69 if (device_ref != 0) {
69 EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true); 70 EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true);
70 if (enter_device_ref.failed()) 71 if (enter_device_ref.failed())
71 return enter.SetResult(PP_ERROR_BADRESOURCE); 72 return enter.SetResult(PP_ERROR_BADRESOURCE);
72 device_id = enter_device_ref.object()->GetDeviceRefData().id; 73 device_id = enter_device_ref.object()->GetDeviceRefData().id;
73 } 74 }
74 75
75 return enter.SetResult(enter.object()->Open( 76 return enter.SetResult(enter.object()->Open(
76 device_id, config, audio_input_callback, user_data, callback)); 77 device_id, config, audio_input_callback, user_data, enter.callback()));
77 } 78 }
78 79
79 PP_Resource GetCurrentConfig(PP_Resource audio_input) { 80 PP_Resource GetCurrentConfig(PP_Resource audio_input) {
80 EnterAudioInput enter(audio_input, true); 81 EnterAudioInput enter(audio_input, true);
81 if (enter.failed()) 82 if (enter.failed())
82 return 0; 83 return 0;
83 return enter.object()->GetCurrentConfig(); 84 return enter.object()->GetCurrentConfig();
84 } 85 }
85 86
86 PP_Bool StartCapture(PP_Resource audio_input) { 87 PP_Bool StartCapture(PP_Resource audio_input) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const PPB_AudioInput_Dev_0_1* GetPPB_AudioInput_Dev_0_1_Thunk() { 130 const PPB_AudioInput_Dev_0_1* GetPPB_AudioInput_Dev_0_1_Thunk() {
130 return &g_ppb_audioinput_0_1_thunk; 131 return &g_ppb_audioinput_0_1_thunk;
131 } 132 }
132 133
133 const PPB_AudioInput_Dev_0_2* GetPPB_AudioInput_Dev_0_2_Thunk() { 134 const PPB_AudioInput_Dev_0_2* GetPPB_AudioInput_Dev_0_2_Thunk() {
134 return &g_ppb_audioinput_0_2_thunk; 135 return &g_ppb_audioinput_0_2_thunk;
135 } 136 }
136 137
137 } // namespace thunk 138 } // namespace thunk
138 } // namespace ppapi 139 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698