Make certificate viewer a tab-modal dialog.
[chromium-blink-merge.git] / ppapi / thunk / ppb_audio_input_dev_thunk.cc
blob2a787370a37233e240e8c3e52ec223069d03e52a
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"
17 namespace ppapi {
18 namespace thunk {
20 namespace {
22 PP_Resource Create(PP_Instance instance) {
23 VLOG(4) << "PPB_AudioInput_Dev::Create()";
24 EnterResourceCreation enter(instance);
25 if (enter.failed())
26 return 0;
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,
37 PP_Resource* devices,
38 struct PP_CompletionCallback callback) {
39 VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()";
40 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()));
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);
53 if (enter.failed())
54 return enter.retval();
55 return enter.SetResult(enter.object()->EnumerateDevices(output,
56 enter.callback()));
59 int32_t MonitorDeviceChange(PP_Resource audio_input,
60 PP_MonitorDeviceChangeCallback callback,
61 void* user_data) {
62 VLOG(4) << "PPB_AudioInput_Dev::MonitorDeviceChange()";
63 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
64 if (enter.failed())
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,
71 PP_Resource config,
72 PPB_AudioInput_Callback audio_input_callback,
73 void* user_data,
74 struct PP_CompletionCallback callback) {
75 VLOG(4) << "PPB_AudioInput_Dev::Open()";
76 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()));
86 PP_Resource GetCurrentConfig(PP_Resource audio_input) {
87 VLOG(4) << "PPB_AudioInput_Dev::GetCurrentConfig()";
88 EnterResource<PPB_AudioInput_API> enter(audio_input, true);
89 if (enter.failed())
90 return 0;
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);
97 if (enter.failed())
98 return PP_FALSE;
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);
105 if (enter.failed())
106 return PP_FALSE;
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);
113 if (enter.failed())
114 return;
115 enter.object()->Close();
118 const PPB_AudioInput_Dev_0_2 g_ppb_audioinput_dev_thunk_0_2 = {
119 &Create,
120 &IsAudioInput,
121 &EnumerateDevices_0_2,
122 &Open,
123 &GetCurrentConfig,
124 &StartCapture,
125 &StopCapture,
126 &Close
129 const PPB_AudioInput_Dev_0_3 g_ppb_audioinput_dev_thunk_0_3 = {
130 &Create,
131 &IsAudioInput,
132 &EnumerateDevices,
133 &MonitorDeviceChange,
134 &Open,
135 &GetCurrentConfig,
136 &StartCapture,
137 &StopCapture,
138 &Close
141 } // namespace
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;
151 } // namespace thunk
152 } // namespace ppapi