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/webrtc_audio_capturer.h" | 5 #include "content/renderer/media/webrtc_audio_capturer.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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 DCHECK_EQ(buffer_size * 100, sample_rate) << | 45 DCHECK_EQ(buffer_size * 100, sample_rate) << |
46 "Sample rate not supported"; | 46 "Sample rate not supported"; |
47 } | 47 } |
48 #elif defined(OS_LINUX) || defined(OS_OPENBSD) | 48 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
49 // Based on tests using the current ALSA implementation in Chrome, we have | 49 // Based on tests using the current ALSA implementation in Chrome, we have |
50 // found that the best combination is 20ms on the input side and 10ms on the | 50 // found that the best combination is 20ms on the input side and 10ms on the |
51 // output side. | 51 // output side. |
52 // TODO(henrika): It might be possible to reduce the input buffer | 52 // TODO(henrika): It might be possible to reduce the input buffer |
53 // size and reduce the delay even more. | 53 // size and reduce the delay even more. |
54 buffer_size = 2 * sample_rate / 100; | 54 buffer_size = 2 * sample_rate / 100; |
| 55 #elif defined(OS_ANDROID) |
| 56 // TODO(leozwang): Tune and adjust buffer size on Android. |
| 57 buffer_size = 2 * sample_rate / 100; |
55 #endif | 58 #endif |
56 | 59 |
57 return buffer_size; | 60 return buffer_size; |
58 } | 61 } |
59 | 62 |
60 // static | 63 // static |
61 scoped_refptr<WebRtcAudioCapturer> WebRtcAudioCapturer::CreateCapturer() { | 64 scoped_refptr<WebRtcAudioCapturer> WebRtcAudioCapturer::CreateCapturer() { |
62 scoped_refptr<WebRtcAudioCapturer> capturer = new WebRtcAudioCapturer(); | 65 scoped_refptr<WebRtcAudioCapturer> capturer = new WebRtcAudioCapturer(); |
63 return capturer; | 66 return capturer; |
64 } | 67 } |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 // Inform the local renderer about the stopped device. | 420 // Inform the local renderer about the stopped device. |
418 // The renderer can then save resources by not asking for more data from | 421 // The renderer can then save resources by not asking for more data from |
419 // the stopped source. We are on the IO thread but the callback task will | 422 // the stopped source. We are on the IO thread but the callback task will |
420 // be posted on the message loop of the main render thread thanks to | 423 // be posted on the message loop of the main render thread thanks to |
421 // usage of BindToLoop() when the callback was initialized. | 424 // usage of BindToLoop() when the callback was initialized. |
422 if (!on_device_stopped_cb_.is_null()) | 425 if (!on_device_stopped_cb_.is_null()) |
423 on_device_stopped_cb_.Run(); | 426 on_device_stopped_cb_.Run(); |
424 } | 427 } |
425 | 428 |
426 } // namespace content | 429 } // namespace content |
OLD | NEW |