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_0_2(PP_Resource audio_input,
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()->EnumerateDevices0_2(
46 int32_t EnumerateDevices(PP_Resource audio_input,
47 struct PP_ArrayOutput output,
48 struct PP_CompletionCallback callback) {
49 VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()";
50 EnterResource<PPB_AudioInput_API> enter(audio_input, callback, true);
52 return enter.retval();
53 return enter.SetResult(enter.object()->EnumerateDevices(output,
57 int32_t MonitorDeviceChange(PP_Resource audio_input,
58 PP_MonitorDeviceChangeCallback callback,
60 VLOG(4) << "PPB_AudioInput_Dev::MonitorDeviceChange()";
61 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
63 return enter.retval();
64 return enter.object()->MonitorDeviceChange(callback, user_data);
67 int32_t Open_0_2(PP_Resource audio_input,
68 PP_Resource device_ref,
70 PPB_AudioInput_Callback_0_2 audio_input_callback,
72 struct PP_CompletionCallback callback) {
73 VLOG(4) << "PPB_AudioInput_Dev::Open()";
74 EnterResource<PPB_AudioInput_API> enter(audio_input, callback, true);
76 return enter.retval();
77 return enter.SetResult(enter.object()->Open0_2(device_ref,
84 int32_t Open(PP_Resource audio_input,
85 PP_Resource device_ref,
87 PPB_AudioInput_Callback audio_input_callback,
89 struct PP_CompletionCallback callback) {
90 VLOG(4) << "PPB_AudioInput_Dev::Open()";
91 EnterResource<PPB_AudioInput_API> enter(audio_input, callback, true);
93 return enter.retval();
94 return enter.SetResult(enter.object()->Open(device_ref,
101 PP_Resource GetCurrentConfig(PP_Resource audio_input) {
102 VLOG(4) << "PPB_AudioInput_Dev::GetCurrentConfig()";
103 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
106 return enter.object()->GetCurrentConfig();
109 PP_Bool StartCapture(PP_Resource audio_input) {
110 VLOG(4) << "PPB_AudioInput_Dev::StartCapture()";
111 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
114 return enter.object()->StartCapture();
117 PP_Bool StopCapture(PP_Resource audio_input) {
118 VLOG(4) << "PPB_AudioInput_Dev::StopCapture()";
119 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
122 return enter.object()->StopCapture();
125 void Close(PP_Resource audio_input) {
126 VLOG(4) << "PPB_AudioInput_Dev::Close()";
127 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
130 enter.object()->Close();
133 const PPB_AudioInput_Dev_0_2 g_ppb_audioinput_dev_thunk_0_2 = {
136 &EnumerateDevices_0_2,
144 const PPB_AudioInput_Dev_0_3 g_ppb_audioinput_dev_thunk_0_3 = {
148 &MonitorDeviceChange,
156 const PPB_AudioInput_Dev_0_4 g_ppb_audioinput_dev_thunk_0_4 = {
160 &MonitorDeviceChange,
170 const PPB_AudioInput_Dev_0_2* GetPPB_AudioInput_Dev_0_2_Thunk() {
171 return &g_ppb_audioinput_dev_thunk_0_2;
174 const PPB_AudioInput_Dev_0_3* GetPPB_AudioInput_Dev_0_3_Thunk() {
175 return &g_ppb_audioinput_dev_thunk_0_3;
178 const PPB_AudioInput_Dev_0_4* GetPPB_AudioInput_Dev_0_4_Thunk() {
179 return &g_ppb_audioinput_dev_thunk_0_4;