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 "base/numerics/safe_conversions.h" |
9 #include "ipc/ipc_platform_file.h" | 10 #include "ipc/ipc_platform_file.h" |
10 #include "media/audio/audio_parameters.h" | 11 #include "media/audio/audio_parameters.h" |
11 #include "media/base/audio_bus.h" | 12 #include "media/base/audio_bus.h" |
12 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
14 #include "ppapi/proxy/resource_message_params.h" | 15 #include "ppapi/proxy/resource_message_params.h" |
15 #include "ppapi/proxy/serialized_handle.h" | 16 #include "ppapi/proxy/serialized_handle.h" |
16 #include "ppapi/shared_impl/ppapi_globals.h" | 17 #include "ppapi/shared_impl/ppapi_globals.h" |
17 #include "ppapi/shared_impl/ppb_audio_config_shared.h" | 18 #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
18 #include "ppapi/shared_impl/resource_tracker.h" | 19 #include "ppapi/shared_impl/resource_tracker.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 audio_input_thread_.reset(); | 243 audio_input_thread_.reset(); |
243 } | 244 } |
244 } | 245 } |
245 | 246 |
246 void AudioInputResource::Run() { | 247 void AudioInputResource::Run() { |
247 // The shared memory represents AudioInputBufferParameters and the actual data | 248 // The shared memory represents AudioInputBufferParameters and the actual data |
248 // buffer stored as an audio bus. | 249 // buffer stored as an audio bus. |
249 media::AudioInputBuffer* buffer = | 250 media::AudioInputBuffer* buffer = |
250 static_cast<media::AudioInputBuffer*>(shared_memory_->memory()); | 251 static_cast<media::AudioInputBuffer*>(shared_memory_->memory()); |
251 const uint32_t audio_bus_size_bytes = | 252 const uint32_t audio_bus_size_bytes = |
252 shared_memory_size_ - sizeof(media::AudioInputBufferParameters); | 253 base::checked_cast<uint32_t>(shared_memory_size_ - |
| 254 sizeof(media::AudioInputBufferParameters)); |
253 | 255 |
254 while (true) { | 256 while (true) { |
255 int pending_data = 0; | 257 int pending_data = 0; |
256 size_t bytes_read = socket_->Receive(&pending_data, sizeof(pending_data)); | 258 size_t bytes_read = socket_->Receive(&pending_data, sizeof(pending_data)); |
257 if (bytes_read != sizeof(pending_data)) { | 259 if (bytes_read != sizeof(pending_data)) { |
258 DCHECK_EQ(bytes_read, 0U); | 260 DCHECK_EQ(bytes_read, 0U); |
259 break; | 261 break; |
260 } | 262 } |
261 if (pending_data < 0) | 263 if (pending_data < 0) |
262 break; | 264 break; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 device_id, enter_config.object()->GetSampleRate(), | 331 device_id, enter_config.object()->GetSampleRate(), |
330 enter_config.object()->GetSampleFrameCount()); | 332 enter_config.object()->GetSampleFrameCount()); |
331 Call<PpapiPluginMsg_AudioInput_OpenReply>( | 333 Call<PpapiPluginMsg_AudioInput_OpenReply>( |
332 RENDERER, msg, | 334 RENDERER, msg, |
333 base::Bind(&AudioInputResource::OnPluginMsgOpenReply, | 335 base::Bind(&AudioInputResource::OnPluginMsgOpenReply, |
334 base::Unretained(this))); | 336 base::Unretained(this))); |
335 return PP_OK_COMPLETIONPENDING; | 337 return PP_OK_COMPLETIONPENDING; |
336 } | 338 } |
337 } // namespace proxy | 339 } // namespace proxy |
338 } // namespace ppapi | 340 } // namespace ppapi |
OLD | NEW |