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 "ppapi/shared_impl/ppb_audio_input_shared.h" | 5 #include "ppapi/shared_impl/ppb_audio_input_shared.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/audio/audio_parameters.h" | 8 #include "media/audio/audio_parameters.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/shared_impl/ppapi_globals.h" | 10 #include "ppapi/shared_impl/ppapi_globals.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 int32_t result, | 133 int32_t result, |
134 const std::vector<DeviceRefData>& devices) { | 134 const std::vector<DeviceRefData>& devices) { |
135 DCHECK(TrackedCallback::IsPending(enumerate_devices_callback_)); | 135 DCHECK(TrackedCallback::IsPending(enumerate_devices_callback_)); |
136 | 136 |
137 if (result == PP_OK && devices_) { | 137 if (result == PP_OK && devices_) { |
138 *devices_ = PPB_DeviceRef_Shared::CreateResourceArray( | 138 *devices_ = PPB_DeviceRef_Shared::CreateResourceArray( |
139 resource_object_type_, pp_instance(), devices); | 139 resource_object_type_, pp_instance(), devices); |
140 } | 140 } |
141 devices_ = NULL; | 141 devices_ = NULL; |
142 | 142 |
143 TrackedCallback::ClearAndRun(&enumerate_devices_callback_, result); | 143 enumerate_devices_callback_->Run(result); |
144 } | 144 } |
145 | 145 |
146 void PPB_AudioInput_Shared::OnOpenComplete( | 146 void PPB_AudioInput_Shared::OnOpenComplete( |
147 int32_t result, | 147 int32_t result, |
148 base::SharedMemoryHandle shared_memory_handle, | 148 base::SharedMemoryHandle shared_memory_handle, |
149 size_t shared_memory_size, | 149 size_t shared_memory_size, |
150 base::SyncSocket::Handle socket_handle) { | 150 base::SyncSocket::Handle socket_handle) { |
151 if (open_state_ == BEFORE_OPEN && result == PP_OK) { | 151 if (open_state_ == BEFORE_OPEN && result == PP_OK) { |
152 open_state_ = OPENED; | 152 open_state_ = OPENED; |
153 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); | 153 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); |
154 } else { | 154 } else { |
155 // Clean up the handles. | 155 // Clean up the handles. |
156 base::SyncSocket temp_socket(socket_handle); | 156 base::SyncSocket temp_socket(socket_handle); |
157 base::SharedMemory temp_mem(shared_memory_handle, false); | 157 base::SharedMemory temp_mem(shared_memory_handle, false); |
158 capturing_ = false; | 158 capturing_ = false; |
159 } | 159 } |
160 | 160 |
161 // The callback may have been aborted by Close(). | 161 // The callback may have been aborted by Close(). |
162 if (TrackedCallback::IsPending(open_callback_)) | 162 if (TrackedCallback::IsPending(open_callback_)) |
163 TrackedCallback::ClearAndRun(&open_callback_, result); | 163 open_callback_->Run(result); |
164 } | 164 } |
165 | 165 |
166 // static | 166 // static |
167 scoped_refptr<TrackedCallback> | 167 scoped_refptr<TrackedCallback> |
168 PPB_AudioInput_Shared::MakeIgnoredCompletionCallback( | 168 PPB_AudioInput_Shared::MakeIgnoredCompletionCallback( |
169 Resource* resource) { | 169 Resource* resource) { |
170 return new TrackedCallback(resource, | 170 return new TrackedCallback(resource, |
171 PP_MakeCompletionCallback(&IgnoredCompletionCallback, NULL)); | 171 PP_MakeCompletionCallback(&IgnoredCompletionCallback, NULL)); |
172 } | 172 } |
173 | 173 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 269 |
270 config_ = config; | 270 config_ = config; |
271 audio_input_callback_ = audio_input_callback; | 271 audio_input_callback_ = audio_input_callback; |
272 user_data_ = user_data; | 272 user_data_ = user_data; |
273 | 273 |
274 return InternalOpen(device_id, enter_config.object()->GetSampleRate(), | 274 return InternalOpen(device_id, enter_config.object()->GetSampleRate(), |
275 enter_config.object()->GetSampleFrameCount(), callback); | 275 enter_config.object()->GetSampleFrameCount(), callback); |
276 } | 276 } |
277 | 277 |
278 } // namespace ppapi | 278 } // namespace ppapi |
OLD | NEW |