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
3 // found in the LICENSE file.
5 // From dev/ppb_audio_input_dev.idl modified Tue Apr 16 11:25:44 2013.
7 #include "ppapi/c/dev/ppb_audio_input_dev.h"
8 #include "ppapi/c/pp_completion_callback.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppb_audio_input_api.h"
13 #include "ppapi/thunk/ppb_instance_api.h"
14 #include "ppapi/thunk/resource_creation_api.h"
15 #include "ppapi/thunk/thunk.h"
22 PP_Resource
Create(PP_Instance instance
) {
23 VLOG(4) << "PPB_AudioInput_Dev::Create()";
24 EnterResourceCreation
enter(instance
);
27 return enter
.functions()->CreateAudioInput(instance
);
30 PP_Bool
IsAudioInput(PP_Resource resource
) {
31 VLOG(4) << "PPB_AudioInput_Dev::IsAudioInput()";
32 EnterResource
<PPB_AudioInput_API
> enter(resource
, false);
33 return PP_FromBool(enter
.succeeded());
36 int32_t EnumerateDevices_0_2(PP_Resource audio_input
,
38 struct PP_CompletionCallback callback
) {
39 VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()";
40 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, callback
, true);
42 return enter
.retval();
43 return enter
.SetResult(enter
.object()->EnumerateDevices0_2(
48 int32_t EnumerateDevices(PP_Resource audio_input
,
49 struct PP_ArrayOutput output
,
50 struct PP_CompletionCallback callback
) {
51 VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()";
52 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, callback
, true);
54 return enter
.retval();
55 return enter
.SetResult(enter
.object()->EnumerateDevices(output
,
59 int32_t MonitorDeviceChange(PP_Resource audio_input
,
60 PP_MonitorDeviceChangeCallback callback
,
62 VLOG(4) << "PPB_AudioInput_Dev::MonitorDeviceChange()";
63 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
65 return enter
.retval();
66 return enter
.object()->MonitorDeviceChange(callback
, user_data
);
69 int32_t Open(PP_Resource audio_input
,
70 PP_Resource device_ref
,
72 PPB_AudioInput_Callback audio_input_callback
,
74 struct PP_CompletionCallback callback
) {
75 VLOG(4) << "PPB_AudioInput_Dev::Open()";
76 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, callback
, true);
78 return enter
.retval();
79 return enter
.SetResult(enter
.object()->Open(device_ref
,
86 PP_Resource
GetCurrentConfig(PP_Resource audio_input
) {
87 VLOG(4) << "PPB_AudioInput_Dev::GetCurrentConfig()";
88 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
91 return enter
.object()->GetCurrentConfig();
94 PP_Bool
StartCapture(PP_Resource audio_input
) {
95 VLOG(4) << "PPB_AudioInput_Dev::StartCapture()";
96 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
99 return enter
.object()->StartCapture();
102 PP_Bool
StopCapture(PP_Resource audio_input
) {
103 VLOG(4) << "PPB_AudioInput_Dev::StopCapture()";
104 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
107 return enter
.object()->StopCapture();
110 void Close(PP_Resource audio_input
) {
111 VLOG(4) << "PPB_AudioInput_Dev::Close()";
112 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
115 enter
.object()->Close();
118 const PPB_AudioInput_Dev_0_2 g_ppb_audioinput_dev_thunk_0_2
= {
121 &EnumerateDevices_0_2
,
129 const PPB_AudioInput_Dev_0_3 g_ppb_audioinput_dev_thunk_0_3
= {
133 &MonitorDeviceChange
,
143 const PPB_AudioInput_Dev_0_2
* GetPPB_AudioInput_Dev_0_2_Thunk() {
144 return &g_ppb_audioinput_dev_thunk_0_2
;
147 const PPB_AudioInput_Dev_0_3
* GetPPB_AudioInput_Dev_0_3_Thunk() {
148 return &g_ppb_audioinput_dev_thunk_0_3
;