OLD | NEW |
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/c/trusted/ppb_audio_input_trusted_dev.h" | 6 #include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h" |
7 #include "ppapi/thunk/common.h" | |
8 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
9 #include "ppapi/thunk/ppb_audio_input_api.h" | 8 #include "ppapi/thunk/ppb_audio_input_api.h" |
10 #include "ppapi/thunk/resource_creation_api.h" | 9 #include "ppapi/thunk/resource_creation_api.h" |
11 #include "ppapi/thunk/thunk.h" | 10 #include "ppapi/thunk/thunk.h" |
12 | 11 |
13 namespace ppapi { | 12 namespace ppapi { |
14 namespace thunk { | 13 namespace thunk { |
15 | 14 |
16 namespace { | 15 namespace { |
17 | 16 |
18 typedef EnterResource<PPB_AudioInput_API> EnterAudioInput; | 17 typedef EnterResource<PPB_AudioInput_API> EnterAudioInput; |
19 | 18 |
20 PP_Resource Create(PP_Instance instance_id) { | 19 PP_Resource Create(PP_Instance instance_id) { |
21 EnterFunction<ResourceCreationAPI> enter(instance_id, true); | 20 EnterFunction<ResourceCreationAPI> enter(instance_id, true); |
22 if (enter.failed()) | 21 if (enter.failed()) |
23 return 0; | 22 return 0; |
24 return enter.functions()->CreateAudioInputTrusted(instance_id); | 23 return enter.functions()->CreateAudioInputTrusted(instance_id); |
25 } | 24 } |
26 | 25 |
27 int32_t Open(PP_Resource audio_id, | 26 int32_t Open(PP_Resource audio_id, |
28 PP_Resource config_id, | 27 PP_Resource config_id, |
29 PP_CompletionCallback create_callback) { | 28 PP_CompletionCallback callback) { |
30 EnterAudioInput enter(audio_id, true); | 29 EnterAudioInput enter(audio_id, callback, true); |
31 if (enter.failed()) | 30 if (enter.failed()) |
32 return MayForceCallback(create_callback, PP_ERROR_BADRESOURCE); | 31 return enter.retval(); |
33 int32_t result = enter.object()->OpenTrusted(config_id, create_callback); | 32 return enter.SetResult(enter.object()->OpenTrusted(config_id, callback)); |
34 return MayForceCallback(create_callback, result); | |
35 } | 33 } |
36 | 34 |
37 int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) { | 35 int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) { |
38 EnterAudioInput enter(audio_id, true); | 36 EnterAudioInput enter(audio_id, true); |
39 if (enter.failed()) | 37 if (enter.failed()) |
40 return PP_ERROR_BADRESOURCE; | 38 return enter.retval(); |
41 return enter.object()->GetSyncSocket(sync_socket); | 39 return enter.object()->GetSyncSocket(sync_socket); |
42 } | 40 } |
43 | 41 |
44 int32_t GetSharedMemory(PP_Resource audio_id, | 42 int32_t GetSharedMemory(PP_Resource audio_id, |
45 int* shm_handle, | 43 int* shm_handle, |
46 uint32_t* shm_size) { | 44 uint32_t* shm_size) { |
47 EnterAudioInput enter(audio_id, true); | 45 EnterAudioInput enter(audio_id, true); |
48 if (enter.failed()) | 46 if (enter.failed()) |
49 return PP_ERROR_BADRESOURCE; | 47 return enter.retval(); |
50 return enter.object()->GetSharedMemory(shm_handle, shm_size); | 48 return enter.object()->GetSharedMemory(shm_handle, shm_size); |
51 } | 49 } |
52 | 50 |
53 const PPB_AudioInputTrusted_Dev g_ppb_audioinput_trusted_thunk = { | 51 const PPB_AudioInputTrusted_Dev g_ppb_audioinput_trusted_thunk = { |
54 &Create, | 52 &Create, |
55 &Open, | 53 &Open, |
56 &GetSyncSocket, | 54 &GetSyncSocket, |
57 &GetSharedMemory, | 55 &GetSharedMemory, |
58 }; | 56 }; |
59 | 57 |
60 } // namespace | 58 } // namespace |
61 | 59 |
62 const PPB_AudioInputTrusted_Dev_0_1* GetPPB_AudioInputTrusted_0_1_Thunk() { | 60 const PPB_AudioInputTrusted_Dev_0_1* GetPPB_AudioInputTrusted_0_1_Thunk() { |
63 return &g_ppb_audioinput_trusted_thunk; | 61 return &g_ppb_audioinput_trusted_thunk; |
64 } | 62 } |
65 | 63 |
66 } // namespace thunk | 64 } // namespace thunk |
67 } // namespace ppapi | 65 } // namespace ppapi |
OLD | NEW |