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 "content/renderer/media/audio_input_device.h" | 5 #include "content/renderer/media/audio_input_device.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 shared_memory.Map(memory_length_); | 268 shared_memory.Map(memory_length_); |
269 | 269 |
270 base::CancelableSyncSocket* socket = audio_socket_.get(); | 270 base::CancelableSyncSocket* socket = audio_socket_.get(); |
271 | 271 |
272 const int samples_per_ms = | 272 const int samples_per_ms = |
273 static_cast<int>(audio_parameters_.sample_rate) / 1000; | 273 static_cast<int>(audio_parameters_.sample_rate) / 1000; |
274 const int bytes_per_ms = audio_parameters_.channels * | 274 const int bytes_per_ms = audio_parameters_.channels * |
275 (audio_parameters_.bits_per_sample / 8) * samples_per_ms; | 275 (audio_parameters_.bits_per_sample / 8) * samples_per_ms; |
276 | 276 |
277 while (true) { | 277 while (true) { |
278 uint32 pending_data = 0; | 278 int pending_data = 0; |
279 size_t received = socket->Receive(&pending_data, sizeof(pending_data)); | 279 size_t received = socket->Receive(&pending_data, sizeof(pending_data)); |
280 if (received != sizeof(pending_data)) { | 280 if (received != sizeof(pending_data)) { |
281 DCHECK(received == 0U); | 281 DCHECK(received == 0U); |
282 break; | 282 break; |
283 } | 283 } |
284 // TODO(henrika): investigate the provided |pending_data| value | 284 // TODO(henrika): investigate the provided |pending_data| value |
285 // and ensure that it is actually an accurate delay estimation. | 285 // and ensure that it is actually an accurate delay estimation. |
286 | 286 |
287 // Convert the number of pending bytes in the capture buffer | 287 // Convert the number of pending bytes in the capture buffer |
288 // into milliseconds. | 288 // into milliseconds. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // Close the socket to terminate the main thread function in the | 330 // Close the socket to terminate the main thread function in the |
331 // audio thread. | 331 // audio thread. |
332 audio_socket_->Shutdown(); // Stops blocking Receive calls. | 332 audio_socket_->Shutdown(); // Stops blocking Receive calls. |
333 // TODO(tommi): We must not do this from the IO thread. Fix. | 333 // TODO(tommi): We must not do this from the IO thread. Fix. |
334 base::ThreadRestrictions::ScopedAllowIO allow_wait; | 334 base::ThreadRestrictions::ScopedAllowIO allow_wait; |
335 audio_thread_->Join(); | 335 audio_thread_->Join(); |
336 audio_thread_.reset(NULL); | 336 audio_thread_.reset(NULL); |
337 audio_socket_.reset(); | 337 audio_socket_.reset(); |
338 } | 338 } |
339 } | 339 } |
OLD | NEW |