OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/plugins/ppapi/ppb_audio_input_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_audio_input_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 int32_t PPB_AudioInput_Impl::InternalEnumerateDevices( | 105 int32_t PPB_AudioInput_Impl::InternalEnumerateDevices( |
106 PP_Resource* devices, | 106 PP_Resource* devices, |
107 scoped_refptr<TrackedCallback> callback) { | 107 scoped_refptr<TrackedCallback> callback) { |
108 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 108 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
109 if (!plugin_delegate) | 109 if (!plugin_delegate) |
110 return PP_ERROR_FAILED; | 110 return PP_ERROR_FAILED; |
111 | 111 |
112 devices_ = devices; | 112 devices_ = devices; |
113 enumerate_devices_callback_ = callback; | 113 enumerate_devices_callback_ = callback; |
114 plugin_delegate->EnumerateDevices( | 114 enumeration_request_id_ = plugin_delegate->EnumerateDevices( |
115 PP_DEVICETYPE_DEV_AUDIOCAPTURE, | 115 PP_DEVICETYPE_DEV_AUDIOCAPTURE, |
116 base::Bind(&PPB_AudioInput_Impl::EnumerateDevicesCallbackFunc, | 116 base::Bind(&PPB_AudioInput_Impl::EnumerateDevicesCallbackFunc, |
117 AsWeakPtr())); | 117 AsWeakPtr())); |
118 return PP_OK_COMPLETIONPENDING; | 118 return PP_OK_COMPLETIONPENDING; |
119 } | 119 } |
120 | 120 |
| 121 int32_t PPB_AudioInput_Impl::InternalStopEnumerateDevices( |
| 122 PP_Resource* devices) { |
| 123 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 124 if (!plugin_delegate) |
| 125 return PP_ERROR_FAILED; |
| 126 |
| 127 if (devices_ == devices) { |
| 128 plugin_delegate->StopEnumerateDevices(enumeration_request_id_); |
| 129 } |
| 130 return PP_OK; |
| 131 } |
| 132 |
121 int32_t PPB_AudioInput_Impl::InternalOpen( | 133 int32_t PPB_AudioInput_Impl::InternalOpen( |
122 const std::string& device_id, | 134 const std::string& device_id, |
123 PP_AudioSampleRate sample_rate, | 135 PP_AudioSampleRate sample_rate, |
124 uint32_t sample_frame_count, | 136 uint32_t sample_frame_count, |
125 scoped_refptr<TrackedCallback> callback) { | 137 scoped_refptr<TrackedCallback> callback) { |
126 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 138 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
127 if (!plugin_delegate) | 139 if (!plugin_delegate) |
128 return PP_ERROR_FAILED; | 140 return PP_ERROR_FAILED; |
129 | 141 |
130 // When the stream is created, we'll get called back on StreamCreated(). | 142 // When the stream is created, we'll get called back on StreamCreated(). |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 const DeviceRefDataVector& devices) { | 185 const DeviceRefDataVector& devices) { |
174 devices_data_.clear(); | 186 devices_data_.clear(); |
175 if (succeeded) | 187 if (succeeded) |
176 devices_data_ = devices; | 188 devices_data_ = devices; |
177 | 189 |
178 OnEnumerateDevicesComplete(succeeded ? PP_OK : PP_ERROR_FAILED, devices); | 190 OnEnumerateDevicesComplete(succeeded ? PP_OK : PP_ERROR_FAILED, devices); |
179 } | 191 } |
180 | 192 |
181 } // namespace ppapi | 193 } // namespace ppapi |
182 } // namespace webkit | 194 } // namespace webkit |
OLD | NEW |