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 "media/audio/audio_input_device.h" | 5 #include "media/audio/audio_input_device.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "media/audio/audio_manager_base.h" | 11 #include "media/audio/audio_manager_base.h" |
12 #include "media/base/audio_bus.h" | 12 #include "media/base/audio_bus.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 | 15 |
16 // The number of shared memory buffer segments indicated to browser process | 16 // The number of shared memory buffer segments indicated to browser process |
17 // in order to avoid data overwriting. This number can be any positive number, | 17 // in order to avoid data overwriting. This number can be any positive number, |
18 // dependent how fast the renderer process can pick up captured data from | 18 // dependent how fast the renderer process can pick up captured data from |
19 // shared memory. | 19 // shared memory. |
20 static const int kRequestedSharedMemoryCount = 10; | 20 // TODO(henrika): figure out a suitable size of this ring buffer. |
| 21 // We have seen reports in Chrome where segments of repeated input audio has |
| 22 // damaged AEC performance in WebRTC clients. By setting its value to 1, we |
| 23 // reduce the number of places in Chrome where such a patteren could possibly |
| 24 // be created. The original value of kRequestedSharedMemoryCount was 10. |
| 25 // See b/13976602 for details. |
| 26 static const int kRequestedSharedMemoryCount = 1; |
21 | 27 |
22 // Takes care of invoking the capture callback on the audio thread. | 28 // Takes care of invoking the capture callback on the audio thread. |
23 // An instance of this class is created for each capture stream in | 29 // An instance of this class is created for each capture stream in |
24 // OnLowLatencyCreated(). | 30 // OnLowLatencyCreated(). |
25 class AudioInputDevice::AudioThreadCallback | 31 class AudioInputDevice::AudioThreadCallback |
26 : public AudioDeviceThread::Callback { | 32 : public AudioDeviceThread::Callback { |
27 public: | 33 public: |
28 AudioThreadCallback(const AudioParameters& audio_parameters, | 34 AudioThreadCallback(const AudioParameters& audio_parameters, |
29 base::SharedMemoryHandle memory, | 35 base::SharedMemoryHandle memory, |
30 int memory_length, | 36 int memory_length, |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // and update the audio-delay measurement. | 320 // and update the audio-delay measurement. |
315 int audio_delay_milliseconds = pending_data / bytes_per_ms_; | 321 int audio_delay_milliseconds = pending_data / bytes_per_ms_; |
316 capture_callback_->Capture( | 322 capture_callback_->Capture( |
317 audio_bus, audio_delay_milliseconds, volume, key_pressed); | 323 audio_bus, audio_delay_milliseconds, volume, key_pressed); |
318 | 324 |
319 if (++current_segment_id_ >= total_segments_) | 325 if (++current_segment_id_ >= total_segments_) |
320 current_segment_id_ = 0; | 326 current_segment_id_ = 0; |
321 } | 327 } |
322 | 328 |
323 } // namespace media | 329 } // namespace media |
OLD | NEW |