| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/c/pp_errors.h" | |
| 6 #include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h" | |
| 7 #include "ppapi/thunk/common.h" | |
| 8 #include "ppapi/thunk/enter.h" | |
| 9 #include "ppapi/thunk/ppb_audio_input_api.h" | |
| 10 #include "ppapi/thunk/resource_creation_api.h" | |
| 11 #include "ppapi/thunk/thunk.h" | |
| 12 | |
| 13 namespace ppapi { | |
| 14 namespace thunk { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 typedef EnterResource<PPB_AudioInput_API> EnterAudioInput; | |
| 19 | |
| 20 PP_Resource Create(PP_Instance instance_id) { | |
| 21 EnterFunction<ResourceCreationAPI> enter(instance_id, true); | |
| 22 if (enter.failed()) | |
| 23 return 0; | |
| 24 return enter.functions()->CreateAudioInputTrusted(instance_id); | |
| 25 } | |
| 26 | |
| 27 int32_t Open(PP_Resource audio_id, | |
| 28 PP_Resource config_id, | |
| 29 PP_CompletionCallback create_callback) { | |
| 30 EnterAudioInput enter(audio_id, true); | |
| 31 if (enter.failed()) | |
| 32 return MayForceCallback(create_callback, PP_ERROR_BADRESOURCE); | |
| 33 int32_t result = enter.object()->OpenTrusted(config_id, create_callback); | |
| 34 return MayForceCallback(create_callback, result); | |
| 35 } | |
| 36 | |
| 37 int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) { | |
| 38 EnterAudioInput enter(audio_id, true); | |
| 39 if (enter.failed()) | |
| 40 return PP_ERROR_BADRESOURCE; | |
| 41 return enter.object()->GetSyncSocket(sync_socket); | |
| 42 } | |
| 43 | |
| 44 int32_t GetSharedMemory(PP_Resource audio_id, | |
| 45 int* shm_handle, | |
| 46 uint32_t* shm_size) { | |
| 47 EnterAudioInput enter(audio_id, true); | |
| 48 if (enter.failed()) | |
| 49 return PP_ERROR_BADRESOURCE; | |
| 50 return enter.object()->GetSharedMemory(shm_handle, shm_size); | |
| 51 } | |
| 52 | |
| 53 const PPB_AudioInputTrusted_Dev g_ppb_audioinput_trusted_thunk = { | |
| 54 &Create, | |
| 55 &Open, | |
| 56 &GetSyncSocket, | |
| 57 &GetSharedMemory, | |
| 58 }; | |
| 59 | |
| 60 } // namespace | |
| 61 | |
| 62 const PPB_AudioInputTrusted_Dev* GetPPB_AudioInputTrusted_Thunk() { | |
| 63 return &g_ppb_audioinput_trusted_thunk; | |
| 64 } | |
| 65 | |
| 66 } // namespace thunk | |
| 67 } // namespace ppapi | |
| OLD | NEW |