| 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/thunk/common.h" | |
| 7 #include "ppapi/thunk/enter.h" | |
| 8 #include "ppapi/thunk/ppb_audio_input_api.h" | |
| 9 #include "ppapi/thunk/resource_creation_api.h" | |
| 10 #include "ppapi/thunk/thunk.h" | |
| 11 | |
| 12 namespace ppapi { | |
| 13 namespace thunk { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 typedef EnterResource<PPB_AudioInput_API> EnterAudioInput; | |
| 18 | |
| 19 PP_Resource Create(PP_Instance instance, | |
| 20 PP_Resource config_id, | |
| 21 PPB_AudioInput_Callback callback, | |
| 22 void* user_data) { | |
| 23 EnterFunction<ResourceCreationAPI> enter(instance, true); | |
| 24 if (enter.failed()) | |
| 25 return 0; | |
| 26 | |
| 27 return enter.functions()->CreateAudioInput(instance, config_id, | |
| 28 callback, user_data); | |
| 29 } | |
| 30 | |
| 31 PP_Bool IsAudioInput(PP_Resource resource) { | |
| 32 EnterAudioInput enter(resource, false); | |
| 33 return PP_FromBool(enter.succeeded()); | |
| 34 } | |
| 35 | |
| 36 PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { | |
| 37 EnterAudioInput enter(audio_id, true); | |
| 38 if (enter.failed()) | |
| 39 return 0; | |
| 40 return enter.object()->GetCurrentConfig(); | |
| 41 } | |
| 42 | |
| 43 PP_Bool StartCapture(PP_Resource audio_input) { | |
| 44 EnterAudioInput enter(audio_input, true); | |
| 45 if (enter.failed()) | |
| 46 return PP_FALSE; | |
| 47 | |
| 48 return enter.object()->StartCapture(); | |
| 49 } | |
| 50 | |
| 51 PP_Bool StopCapture(PP_Resource audio_input) { | |
| 52 EnterAudioInput enter(audio_input, true); | |
| 53 if (enter.failed()) | |
| 54 return PP_FALSE; | |
| 55 | |
| 56 return enter.object()->StopCapture(); | |
| 57 } | |
| 58 | |
| 59 const PPB_AudioInput_Dev g_ppb_audioinput_thunk = { | |
| 60 &Create, | |
| 61 &IsAudioInput, | |
| 62 &GetCurrentConfiguration, | |
| 63 &StartCapture, | |
| 64 &StopCapture | |
| 65 }; | |
| 66 | |
| 67 } // namespace | |
| 68 | |
| 69 const PPB_AudioInput_Dev* GetPPB_AudioInput_Dev_Thunk() { | |
| 70 return &g_ppb_audioinput_thunk; | |
| 71 } | |
| 72 | |
| 73 } // namespace thunk | |
| 74 } // namespace ppapi | |
| OLD | NEW |