blob: 9eb2e3c277a920e79abf26b4966a350dd50d4e38 [file] [log] [blame]
[email protected]8917a672013-02-25 17:18:041// 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.
4
[email protected]03f8b542013-04-02 17:57:505// From dev/ppb_audio_input_dev.idl modified Thu Mar 28 11:12:59 2013.
[email protected]8917a672013-02-25 17:18:046
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"
16
17namespace ppapi {
18namespace thunk {
19
20namespace {
21
22PP_Resource Create(PP_Instance instance) {
[email protected]03f8b542013-04-02 17:57:5023 VLOG(4) << "PPB_AudioInput_Dev::Create()";
[email protected]8917a672013-02-25 17:18:0424 EnterResourceCreation enter(instance);
25 if (enter.failed())
26 return 0;
27 return enter.functions()->CreateAudioInput(instance);
28}
29
30PP_Bool IsAudioInput(PP_Resource resource) {
[email protected]03f8b542013-04-02 17:57:5031 VLOG(4) << "PPB_AudioInput_Dev::IsAudioInput()";
[email protected]8917a672013-02-25 17:18:0432 EnterResource<PPB_AudioInput_API> enter(resource, false);
33 return PP_FromBool(enter.succeeded());
34}
35
36int32_t EnumerateDevices_0_2(PP_Resource audio_input,
37 PP_Resource* devices,
38 struct PP_CompletionCallback callback) {
[email protected]03f8b542013-04-02 17:57:5039 VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()";
[email protected]8917a672013-02-25 17:18:0440 EnterResource<PPB_AudioInput_API> enter(audio_input, callback, true);
41 if (enter.failed())
42 return enter.retval();
43 return enter.SetResult(enter.object()->EnumerateDevices0_2(
44 devices,
45 enter.callback()));
46}
47
48int32_t EnumerateDevices(PP_Resource audio_input,
49 struct PP_ArrayOutput output,
50 struct PP_CompletionCallback callback) {
[email protected]03f8b542013-04-02 17:57:5051 VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()";
[email protected]8917a672013-02-25 17:18:0452 EnterResource<PPB_AudioInput_API> enter(audio_input, callback, true);
53 if (enter.failed())
54 return enter.retval();
55 return enter.SetResult(enter.object()->EnumerateDevices(output,
56 enter.callback()));
57}
58
59int32_t MonitorDeviceChange(PP_Resource audio_input,
60 PP_MonitorDeviceChangeCallback callback,
61 void* user_data) {
[email protected]03f8b542013-04-02 17:57:5062 VLOG(4) << "PPB_AudioInput_Dev::MonitorDeviceChange()";
[email protected]8917a672013-02-25 17:18:0463 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
64 if (enter.failed())
65 return enter.retval();
66 return enter.object()->MonitorDeviceChange(callback, user_data);
67}
68
69int32_t Open(PP_Resource audio_input,
70 PP_Resource device_ref,
71 PP_Resource config,
72 PPB_AudioInput_Callback audio_input_callback,
73 void* user_data,
74 struct PP_CompletionCallback callback) {
[email protected]03f8b542013-04-02 17:57:5075 VLOG(4) << "PPB_AudioInput_Dev::Open()";
[email protected]8917a672013-02-25 17:18:0476 EnterResource<PPB_AudioInput_API> enter(audio_input, callback, true);
77 if (enter.failed())
78 return enter.retval();
79 return enter.SetResult(enter.object()->Open(device_ref,
80 config,
81 audio_input_callback,
82 user_data,
83 enter.callback()));
84}
85
86PP_Resource GetCurrentConfig(PP_Resource audio_input) {
[email protected]03f8b542013-04-02 17:57:5087 VLOG(4) << "PPB_AudioInput_Dev::GetCurrentConfig()";
[email protected]8917a672013-02-25 17:18:0488 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
89 if (enter.failed())
90 return 0;
91 return enter.object()->GetCurrentConfig();
92}
93
94PP_Bool StartCapture(PP_Resource audio_input) {
[email protected]03f8b542013-04-02 17:57:5095 VLOG(4) << "PPB_AudioInput_Dev::StartCapture()";
[email protected]8917a672013-02-25 17:18:0496 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
97 if (enter.failed())
98 return PP_FALSE;
99 return enter.object()->StartCapture();
100}
101
102PP_Bool StopCapture(PP_Resource audio_input) {
[email protected]03f8b542013-04-02 17:57:50103 VLOG(4) << "PPB_AudioInput_Dev::StopCapture()";
[email protected]8917a672013-02-25 17:18:04104 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
105 if (enter.failed())
106 return PP_FALSE;
107 return enter.object()->StopCapture();
108}
109
110void Close(PP_Resource audio_input) {
[email protected]03f8b542013-04-02 17:57:50111 VLOG(4) << "PPB_AudioInput_Dev::Close()";
[email protected]8917a672013-02-25 17:18:04112 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
113 if (enter.succeeded())
114 enter.object()->Close();
115}
116
117const PPB_AudioInput_Dev_0_2 g_ppb_audioinput_dev_thunk_0_2 = {
118 &Create,
119 &IsAudioInput,
120 &EnumerateDevices_0_2,
121 &Open,
122 &GetCurrentConfig,
123 &StartCapture,
124 &StopCapture,
125 &Close
126};
127
128const PPB_AudioInput_Dev_0_3 g_ppb_audioinput_dev_thunk_0_3 = {
129 &Create,
130 &IsAudioInput,
131 &EnumerateDevices,
132 &MonitorDeviceChange,
133 &Open,
134 &GetCurrentConfig,
135 &StartCapture,
136 &StopCapture,
137 &Close
138};
139
140} // namespace
141
142const PPB_AudioInput_Dev_0_2* GetPPB_AudioInput_Dev_0_2_Thunk() {
143 return &g_ppb_audioinput_dev_thunk_0_2;
144}
145
146const PPB_AudioInput_Dev_0_3* GetPPB_AudioInput_Dev_0_3_Thunk() {
147 return &g_ppb_audioinput_dev_thunk_0_3;
148}
149
150} // namespace thunk
151} // namespace ppapi