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/thunk.h" |
| 9 #include "ppapi/thunk/ppb_audio_input_api.h" |
| 10 #include "ppapi/thunk/resource_creation_api.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 PPB_AudioInput_Callback callback, |
| 21 void* user_data) { |
| 22 EnterFunction<ResourceCreationAPI> enter(instance, true); |
| 23 if (enter.failed()) |
| 24 return 0; |
| 25 |
| 26 return enter.functions()->CreateAudioInput(instance, callback, user_data); |
| 27 } |
| 28 |
| 29 PP_Bool IsAudioInput(PP_Resource resource) { |
| 30 EnterAudioInput enter(resource, false); |
| 31 return PP_FromBool(enter.succeeded()); |
| 32 } |
| 33 |
| 34 PP_Bool StartCapture(PP_Resource audio_input) { |
| 35 EnterAudioInput enter(audio_input, true); |
| 36 if (enter.failed()) |
| 37 return PP_FALSE; |
| 38 |
| 39 return enter.object()->StartCapture(); |
| 40 } |
| 41 |
| 42 PP_Bool StopCapture(PP_Resource audio_input) { |
| 43 EnterAudioInput enter(audio_input, true); |
| 44 if (enter.failed()) |
| 45 return PP_FALSE; |
| 46 |
| 47 return enter.object()->StopCapture(); |
| 48 } |
| 49 |
| 50 const PPB_AudioInput_Dev g_ppb_audioinput_thunk = { |
| 51 &Create, |
| 52 &IsAudioInput, |
| 53 &StartCapture, |
| 54 &StopCapture |
| 55 }; |
| 56 |
| 57 } // namespace |
| 58 |
| 59 const PPB_AudioInput_Dev* GetPPB_AudioInput_Dev_Thunk() { |
| 60 return &g_ppb_audioinput_thunk; |
| 61 } |
| 62 |
| 63 } // namespace thunk |
| 64 } // namespace ppapi |
OLD | NEW |