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

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: export AssertLockHeld Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/thunk/ppb_audio_input_api.h ('k') | ppapi/thunk/ppb_audio_input_trusted_thunk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shared_impl/tracked_callback.h"
7 #include "ppapi/thunk/enter.h" 8 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/ppb_device_ref_api.h" 9 #include "ppapi/thunk/ppb_device_ref_api.h"
9 #include "ppapi/thunk/ppb_audio_input_api.h" 10 #include "ppapi/thunk/ppb_audio_input_api.h"
10 #include "ppapi/thunk/resource_creation_api.h" 11 #include "ppapi/thunk/resource_creation_api.h"
11 #include "ppapi/thunk/thunk.h" 12 #include "ppapi/thunk/thunk.h"
12 13
13 namespace ppapi { 14 namespace ppapi {
14 namespace thunk { 15 namespace thunk {
15 16
16 namespace { 17 namespace {
(...skipping 25 matching lines...) Expand all
42 return PP_FromBool(enter.succeeded()); 43 return PP_FromBool(enter.succeeded());
43 } 44 }
44 45
45 int32_t EnumerateDevices(PP_Resource audio_input, 46 int32_t EnumerateDevices(PP_Resource audio_input,
46 PP_Resource* devices, 47 PP_Resource* devices,
47 PP_CompletionCallback callback) { 48 PP_CompletionCallback callback) {
48 EnterAudioInput enter(audio_input, callback, true); 49 EnterAudioInput enter(audio_input, callback, true);
49 if (enter.failed()) 50 if (enter.failed())
50 return enter.retval(); 51 return enter.retval();
51 52
52 return enter.SetResult(enter.object()->EnumerateDevices(devices, callback)); 53 return enter.SetResult(enter.object()->EnumerateDevices(devices,
54 enter.callback()));
53 } 55 }
54 56
55 int32_t Open(PP_Resource audio_input, 57 int32_t Open(PP_Resource audio_input,
56 PP_Resource device_ref, 58 PP_Resource device_ref,
57 PP_Resource config, 59 PP_Resource config,
58 PPB_AudioInput_Callback audio_input_callback, 60 PPB_AudioInput_Callback audio_input_callback,
59 void* user_data, 61 void* user_data,
60 PP_CompletionCallback callback) { 62 PP_CompletionCallback callback) {
61 EnterAudioInput enter(audio_input, callback, true); 63 EnterAudioInput enter(audio_input, callback, true);
62 if (enter.failed()) 64 if (enter.failed())
63 return enter.retval(); 65 return enter.retval();
64 66
65 std::string device_id; 67 std::string device_id;
66 // |device_id| remains empty if |device_ref| is 0, which means the default 68 // |device_id| remains empty if |device_ref| is 0, which means the default
67 // device. 69 // device.
68 if (device_ref != 0) { 70 if (device_ref != 0) {
69 EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true); 71 EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true);
70 if (enter_device_ref.failed()) 72 if (enter_device_ref.failed())
71 return enter.SetResult(PP_ERROR_BADRESOURCE); 73 return enter.SetResult(PP_ERROR_BADRESOURCE);
72 device_id = enter_device_ref.object()->GetDeviceRefData().id; 74 device_id = enter_device_ref.object()->GetDeviceRefData().id;
73 } 75 }
74 76
75 return enter.SetResult(enter.object()->Open( 77 return enter.SetResult(enter.object()->Open(
76 device_id, config, audio_input_callback, user_data, callback)); 78 device_id, config, audio_input_callback, user_data, enter.callback()));
77 } 79 }
78 80
79 PP_Resource GetCurrentConfig(PP_Resource audio_input) { 81 PP_Resource GetCurrentConfig(PP_Resource audio_input) {
80 EnterAudioInput enter(audio_input, true); 82 EnterAudioInput enter(audio_input, true);
81 if (enter.failed()) 83 if (enter.failed())
82 return 0; 84 return 0;
83 return enter.object()->GetCurrentConfig(); 85 return enter.object()->GetCurrentConfig();
84 } 86 }
85 87
86 PP_Bool StartCapture(PP_Resource audio_input) { 88 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() { 131 const PPB_AudioInput_Dev_0_1* GetPPB_AudioInput_Dev_0_1_Thunk() {
130 return &g_ppb_audioinput_0_1_thunk; 132 return &g_ppb_audioinput_0_1_thunk;
131 } 133 }
132 134
133 const PPB_AudioInput_Dev_0_2* GetPPB_AudioInput_Dev_0_2_Thunk() { 135 const PPB_AudioInput_Dev_0_2* GetPPB_AudioInput_Dev_0_2_Thunk() {
134 return &g_ppb_audioinput_0_2_thunk; 136 return &g_ppb_audioinput_0_2_thunk;
135 } 137 }
136 138
137 } // namespace thunk 139 } // namespace thunk
138 } // namespace ppapi 140 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_audio_input_api.h ('k') | ppapi/thunk/ppb_audio_input_trusted_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698