[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 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. |
| 4 | |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 5 | // From dev/ppb_audio_input_dev.idl modified Thu Mar 28 11:12:59 2013. |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 6 | |
| 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 | |
| 17 | namespace ppapi { |
| 18 | namespace thunk { |
| 19 | |
| 20 | namespace { |
| 21 | |
| 22 | PP_Resource Create(PP_Instance instance) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 23 | VLOG(4) << "PPB_AudioInput_Dev::Create()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 24 | EnterResourceCreation enter(instance); |
| 25 | if (enter.failed()) |
| 26 | return 0; |
| 27 | return enter.functions()->CreateAudioInput(instance); |
| 28 | } |
| 29 | |
| 30 | PP_Bool IsAudioInput(PP_Resource resource) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 31 | VLOG(4) << "PPB_AudioInput_Dev::IsAudioInput()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 32 | EnterResource<PPB_AudioInput_API> enter(resource, false); |
| 33 | return PP_FromBool(enter.succeeded()); |
| 34 | } |
| 35 | |
| 36 | int32_t EnumerateDevices_0_2(PP_Resource audio_input, |
| 37 | PP_Resource* devices, |
| 38 | struct PP_CompletionCallback callback) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 39 | VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 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())); |
| 46 | } |
| 47 | |
| 48 | int32_t EnumerateDevices(PP_Resource audio_input, |
| 49 | struct PP_ArrayOutput output, |
| 50 | struct PP_CompletionCallback callback) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 51 | VLOG(4) << "PPB_AudioInput_Dev::EnumerateDevices()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 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())); |
| 57 | } |
| 58 | |
| 59 | int32_t MonitorDeviceChange(PP_Resource audio_input, |
| 60 | PP_MonitorDeviceChangeCallback callback, |
| 61 | void* user_data) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 62 | VLOG(4) << "PPB_AudioInput_Dev::MonitorDeviceChange()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 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); |
| 67 | } |
| 68 | |
| 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) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 75 | VLOG(4) << "PPB_AudioInput_Dev::Open()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 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())); |
| 84 | } |
| 85 | |
| 86 | PP_Resource GetCurrentConfig(PP_Resource audio_input) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 87 | VLOG(4) << "PPB_AudioInput_Dev::GetCurrentConfig()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 88 | EnterResource<PPB_AudioInput_API> enter(audio_input, true); |
| 89 | if (enter.failed()) |
| 90 | return 0; |
| 91 | return enter.object()->GetCurrentConfig(); |
| 92 | } |
| 93 | |
| 94 | PP_Bool StartCapture(PP_Resource audio_input) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 95 | VLOG(4) << "PPB_AudioInput_Dev::StartCapture()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 96 | EnterResource<PPB_AudioInput_API> enter(audio_input, true); |
| 97 | if (enter.failed()) |
| 98 | return PP_FALSE; |
| 99 | return enter.object()->StartCapture(); |
| 100 | } |
| 101 | |
| 102 | PP_Bool StopCapture(PP_Resource audio_input) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 103 | VLOG(4) << "PPB_AudioInput_Dev::StopCapture()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 104 | EnterResource<PPB_AudioInput_API> enter(audio_input, true); |
| 105 | if (enter.failed()) |
| 106 | return PP_FALSE; |
| 107 | return enter.object()->StopCapture(); |
| 108 | } |
| 109 | |
| 110 | void Close(PP_Resource audio_input) { |
[email protected] | 03f8b54 | 2013-04-02 17:57:50 | [diff] [blame^] | 111 | VLOG(4) << "PPB_AudioInput_Dev::Close()"; |
[email protected] | 8917a67 | 2013-02-25 17:18:04 | [diff] [blame] | 112 | EnterResource<PPB_AudioInput_API> enter(audio_input, true); |
| 113 | if (enter.succeeded()) |
| 114 | enter.object()->Close(); |
| 115 | } |
| 116 | |
| 117 | const 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 | |
| 128 | const 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 | |
| 142 | const PPB_AudioInput_Dev_0_2* GetPPB_AudioInput_Dev_0_2_Thunk() { |
| 143 | return &g_ppb_audioinput_dev_thunk_0_2; |
| 144 | } |
| 145 | |
| 146 | const 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 |