Update V8 to version 4.7.47.
[chromium-blink-merge.git] / ppapi / thunk / ppb_audio_input_dev_thunk.cc
blob7d44a03078774db1e2081db0e0f455037794ade0
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"
15 namespace ppapi {
16 namespace thunk {
18 namespace {
20 PP_Resource Create(PP_Instance instance) {
21 VLOG(4) << "PPB_AudioInput_Dev::Create()";
22 EnterResourceCreation enter(instance);
23 if (enter.failed())
24 return 0;
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);
39 if (enter.failed())
40 return enter.retval();
41 return enter.SetResult(enter.object()->EnumerateDevices(output,
42 enter.callback()));
45 int32_t MonitorDeviceChange(PP_Resource audio_input,
46 PP_MonitorDeviceChangeCallback callback,
47 void* user_data) {
48 VLOG(4) << "PPB_AudioInput_Dev::MonitorDeviceChange()";
49 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
50 if (enter.failed())
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,
57 PP_Resource config,
58 PPB_AudioInput_Callback_0_3 audio_input_callback,
59 void* user_data,
60 struct PP_CompletionCallback callback) {
61 VLOG(4) << "PPB_AudioInput_Dev::Open()";
62 EnterResource<PPB_AudioInput_API> enter(audio_input, callback, true);
63 if (enter.failed())
64 return enter.retval();
65 return enter.SetResult(enter.object()->Open0_3(device_ref,
66 config,
67 audio_input_callback,
68 user_data,
69 enter.callback()));
72 int32_t Open(PP_Resource audio_input,
73 PP_Resource device_ref,
74 PP_Resource config,
75 PPB_AudioInput_Callback audio_input_callback,
76 void* user_data,
77 struct PP_CompletionCallback callback) {
78 VLOG(4) << "PPB_AudioInput_Dev::Open()";
79 EnterResource<PPB_AudioInput_API> enter(audio_input, callback, true);
80 if (enter.failed())
81 return enter.retval();
82 return enter.SetResult(enter.object()->Open(device_ref,
83 config,
84 audio_input_callback,
85 user_data,
86 enter.callback()));
89 PP_Resource GetCurrentConfig(PP_Resource audio_input) {
90 VLOG(4) << "PPB_AudioInput_Dev::GetCurrentConfig()";
91 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
92 if (enter.failed())
93 return 0;
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);
100 if (enter.failed())
101 return PP_FALSE;
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);
108 if (enter.failed())
109 return PP_FALSE;
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);
116 if (enter.failed())
117 return;
118 enter.object()->Close();
121 const PPB_AudioInput_Dev_0_3 g_ppb_audioinput_dev_thunk_0_3 = {
122 &Create,
123 &IsAudioInput,
124 &EnumerateDevices,
125 &MonitorDeviceChange,
126 &Open_0_3,
127 &GetCurrentConfig,
128 &StartCapture,
129 &StopCapture,
130 &Close
133 const PPB_AudioInput_Dev_0_4 g_ppb_audioinput_dev_thunk_0_4 = {
134 &Create,
135 &IsAudioInput,
136 &EnumerateDevices,
137 &MonitorDeviceChange,
138 &Open,
139 &GetCurrentConfig,
140 &StartCapture,
141 &StopCapture,
142 &Close
145 } // namespace
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;
155 } // namespace thunk
156 } // namespace ppapi