OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 } | 74 } |
75 | 75 |
76 // Write audio samples in blocks of 10 milliseconds to the registered | 76 // Write audio samples in blocks of 10 milliseconds to the registered |
77 // webrtc::AudioTransport sink. Keep writing until our internal byte | 77 // webrtc::AudioTransport sink. Keep writing until our internal byte |
78 // buffer is empty. | 78 // buffer is empty. |
79 const int16* audio_buffer = audio_data; | 79 const int16* audio_buffer = audio_data; |
80 const int samples_per_10_msec = (sample_rate / 100); | 80 const int samples_per_10_msec = (sample_rate / 100); |
81 CHECK_EQ(number_of_frames % samples_per_10_msec, 0); | 81 CHECK_EQ(number_of_frames % samples_per_10_msec, 0); |
82 int accumulated_audio_samples = 0; | 82 int accumulated_audio_samples = 0; |
83 uint32_t new_volume = 0; | 83 uint32_t new_volume = 0; |
84 | |
85 // The lock here is to protect the racing in the resampler inside webrtc when | |
86 // there are more than one input streams calling OnData(), which can happen | |
henrika (OOO until Aug 14)
2014/01/09 10:07:14
nit, ...input stream calling...
no longer working on chromium
2014/01/09 10:18:32
Done.
| |
87 // when the users setup two getUserMedia, one for the microphone, another | |
88 // for WebAudio. Currently we don't have a better way to fix it except for | |
89 // adding a lock here to sequence the call. | |
90 // TODO(xians): Remove this workaround after we move the | |
henrika (OOO until Aug 14)
2014/01/09 10:07:14
Add link to crbug issue here.
no longer working on chromium
2014/01/09 10:18:32
Done.
| |
91 // webrtc::AudioProcessing module to Chrome. | |
92 base::AutoLock auto_lock(capture_callback_lock_); | |
84 while (accumulated_audio_samples < number_of_frames) { | 93 while (accumulated_audio_samples < number_of_frames) { |
85 // Deliver 10ms of recorded 16-bit linear PCM audio. | 94 // Deliver 10ms of recorded 16-bit linear PCM audio. |
86 int new_mic_level = audio_transport_callback_->OnDataAvailable( | 95 int new_mic_level = audio_transport_callback_->OnDataAvailable( |
87 &channels[0], | 96 &channels[0], |
88 channels.size(), | 97 channels.size(), |
89 audio_buffer, | 98 audio_buffer, |
90 sample_rate, | 99 sample_rate, |
91 number_of_channels, | 100 number_of_channels, |
92 samples_per_10_msec, | 101 samples_per_10_msec, |
93 total_delay_ms, | 102 total_delay_ms, |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 for (CapturerList::const_iterator iter = capturers_.begin(); | 449 for (CapturerList::const_iterator iter = capturers_.begin(); |
441 iter != capturers_.end(); ++iter) { | 450 iter != capturers_.end(); ++iter) { |
442 if (!(*iter)->device_id().empty()) | 451 if (!(*iter)->device_id().empty()) |
443 return *iter; | 452 return *iter; |
444 } | 453 } |
445 | 454 |
446 return NULL; | 455 return NULL; |
447 } | 456 } |
448 | 457 |
449 } // namespace content | 458 } // namespace content |
OLD | NEW |