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 #include "ppapi/c/dev/ppb_audio_input_dev.h"
6 #include "ppapi/c/pp_completion_callback.h"
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/shared_impl/tracked_callback.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_audio_input_api.h"
11 #include "ppapi/thunk/ppb_instance_api.h"
12 #include "ppapi/thunk/resource_creation_api.h"
13 #include "ppapi/thunk/thunk.h"
20 PP_Resource
Create(PP_Instance instance
) {
21 VLOG(4) << "PPB_AudioInput_Dev::Create()";
22 EnterResourceCreation
enter(instance
);
25 return enter
.functions()->CreateAudioInput(instance
);
28 PP_Bool
IsAudioInput(PP_Resource resource
) {
29 VLOG(4) << "PPB_AudioInput_Dev::IsAudioInput()";
30 EnterResource
<PPB_AudioInput_API
> enter(resource
, false);
31 return PP_FromBool(enter
.succeeded());
34 int32_t EnumerateDevices(PP_Resource audio_input
,
35 struct PP_ArrayOutput output
,
36 struct PP_CompletionCallback callback
) {
37 VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()";
38 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, callback
, true);
40 return enter
.retval();
41 return enter
.SetResult(enter
.object()->EnumerateDevices(output
,
45 int32_t MonitorDeviceChange(PP_Resource audio_input
,
46 PP_MonitorDeviceChangeCallback callback
,
48 VLOG(4) << "PPB_AudioInput_Dev::MonitorDeviceChange()";
49 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
51 return enter
.retval();
52 return enter
.object()->MonitorDeviceChange(callback
, user_data
);
55 int32_t Open_0_3(PP_Resource audio_input
,
56 PP_Resource device_ref
,
58 PPB_AudioInput_Callback_0_3 audio_input_callback
,
60 struct PP_CompletionCallback callback
) {
61 VLOG(4) << "PPB_AudioInput_Dev::Open()";
62 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, callback
, true);
64 return enter
.retval();
65 return enter
.SetResult(enter
.object()->Open0_3(device_ref
,
72 int32_t Open(PP_Resource audio_input
,
73 PP_Resource device_ref
,
75 PPB_AudioInput_Callback audio_input_callback
,
77 struct PP_CompletionCallback callback
) {
78 VLOG(4) << "PPB_AudioInput_Dev::Open()";
79 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, callback
, true);
81 return enter
.retval();
82 return enter
.SetResult(enter
.object()->Open(device_ref
,
89 PP_Resource
GetCurrentConfig(PP_Resource audio_input
) {
90 VLOG(4) << "PPB_AudioInput_Dev::GetCurrentConfig()";
91 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
94 return enter
.object()->GetCurrentConfig();
97 PP_Bool
StartCapture(PP_Resource audio_input
) {
98 VLOG(4) << "PPB_AudioInput_Dev::StartCapture()";
99 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
102 return enter
.object()->StartCapture();
105 PP_Bool
StopCapture(PP_Resource audio_input
) {
106 VLOG(4) << "PPB_AudioInput_Dev::StopCapture()";
107 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
110 return enter
.object()->StopCapture();
113 void Close(PP_Resource audio_input
) {
114 VLOG(4) << "PPB_AudioInput_Dev::Close()";
115 EnterResource
<PPB_AudioInput_API
> enter(audio_input
, true);
118 enter
.object()->Close();
121 const PPB_AudioInput_Dev_0_3 g_ppb_audioinput_dev_thunk_0_3
= {
125 &MonitorDeviceChange
,
133 const PPB_AudioInput_Dev_0_4 g_ppb_audioinput_dev_thunk_0_4
= {
137 &MonitorDeviceChange
,
147 const PPB_AudioInput_Dev_0_3
* GetPPB_AudioInput_Dev_0_3_Thunk() {
148 return &g_ppb_audioinput_dev_thunk_0_3
;
151 const PPB_AudioInput_Dev_0_4
* GetPPB_AudioInput_Dev_0_4_Thunk() {
152 return &g_ppb_audioinput_dev_thunk_0_4
;