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/proxy/audio_input_resource.h" | 5 #include "ppapi/proxy/audio_input_resource.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 "ipc/ipc_platform_file.h" | 9 #include "ipc/ipc_platform_file.h" |
10 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
11 #include "media/audio/shared_memory_util.h" | |
12 #include "ppapi/c/pp_errors.h" | 11 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/proxy/ppapi_messages.h" | 12 #include "ppapi/proxy/ppapi_messages.h" |
14 #include "ppapi/proxy/resource_message_params.h" | 13 #include "ppapi/proxy/resource_message_params.h" |
15 #include "ppapi/proxy/serialized_handle.h" | 14 #include "ppapi/proxy/serialized_handle.h" |
16 #include "ppapi/shared_impl/ppapi_globals.h" | 15 #include "ppapi/shared_impl/ppapi_globals.h" |
17 #include "ppapi/shared_impl/ppb_audio_config_shared.h" | 16 #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
18 #include "ppapi/shared_impl/resource_tracker.h" | 17 #include "ppapi/shared_impl/resource_tracker.h" |
19 #include "ppapi/shared_impl/tracked_callback.h" | 18 #include "ppapi/shared_impl/tracked_callback.h" |
20 #include "ppapi/thunk/enter.h" | 19 #include "ppapi/thunk/enter.h" |
21 #include "ppapi/thunk/ppb_audio_config_api.h" | 20 #include "ppapi/thunk/ppb_audio_config_api.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 IPC::InvalidPlatformFileForTransit(); | 160 IPC::InvalidPlatformFileForTransit(); |
162 params.TakeSocketHandleAtIndex(0, &socket_handle_for_transit); | 161 params.TakeSocketHandleAtIndex(0, &socket_handle_for_transit); |
163 base::SyncSocket::Handle socket_handle = | 162 base::SyncSocket::Handle socket_handle = |
164 IPC::PlatformFileForTransitToPlatformFile(socket_handle_for_transit); | 163 IPC::PlatformFileForTransitToPlatformFile(socket_handle_for_transit); |
165 CHECK(socket_handle != base::SyncSocket::kInvalidHandle); | 164 CHECK(socket_handle != base::SyncSocket::kInvalidHandle); |
166 | 165 |
167 SerializedHandle serialized_shared_memory_handle = | 166 SerializedHandle serialized_shared_memory_handle = |
168 params.TakeHandleOfTypeAtIndex(1, SerializedHandle::SHARED_MEMORY); | 167 params.TakeHandleOfTypeAtIndex(1, SerializedHandle::SHARED_MEMORY); |
169 CHECK(serialized_shared_memory_handle.IsHandleValid()); | 168 CHECK(serialized_shared_memory_handle.IsHandleValid()); |
170 | 169 |
171 // See the comment in pepper_audio_input_host.cc about how we must call | |
172 // TotalSharedMemorySizeInBytes to get the actual size of the buffer. Here, | |
173 // we must call PacketSizeInBytes to get back the size of the audio buffer, | |
174 // excluding the bytes that audio uses for book-keeping. | |
175 size_t shared_memory_size = media::PacketSizeInBytes( | |
176 serialized_shared_memory_handle.size()); | |
177 | |
178 open_state_ = OPENED; | 170 open_state_ = OPENED; |
179 SetStreamInfo(serialized_shared_memory_handle.shmem(), shared_memory_size, | 171 SetStreamInfo(serialized_shared_memory_handle.shmem(), |
| 172 serialized_shared_memory_handle.size(), |
180 socket_handle); | 173 socket_handle); |
181 } else { | 174 } else { |
182 capturing_ = false; | 175 capturing_ = false; |
183 } | 176 } |
184 | 177 |
185 // The callback may have been aborted by Close(). | 178 // The callback may have been aborted by Close(). |
186 if (TrackedCallback::IsPending(open_callback_)) | 179 if (TrackedCallback::IsPending(open_callback_)) |
187 open_callback_->Run(params.result()); | 180 open_callback_->Run(params.result()); |
188 } | 181 } |
189 | 182 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 device_id, enter_config.object()->GetSampleRate(), | 298 device_id, enter_config.object()->GetSampleRate(), |
306 enter_config.object()->GetSampleFrameCount()); | 299 enter_config.object()->GetSampleFrameCount()); |
307 Call<PpapiPluginMsg_AudioInput_OpenReply>( | 300 Call<PpapiPluginMsg_AudioInput_OpenReply>( |
308 RENDERER, msg, | 301 RENDERER, msg, |
309 base::Bind(&AudioInputResource::OnPluginMsgOpenReply, | 302 base::Bind(&AudioInputResource::OnPluginMsgOpenReply, |
310 base::Unretained(this))); | 303 base::Unretained(this))); |
311 return PP_OK_COMPLETIONPENDING; | 304 return PP_OK_COMPLETIONPENDING; |
312 } | 305 } |
313 } // namespace proxy | 306 } // namespace proxy |
314 } // namespace ppapi | 307 } // namespace ppapi |
OLD | NEW |