OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void VoiceDetectionImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 56 void VoiceDetectionImpl::ProcessCaptureAudio(AudioBuffer* audio) { |
57 rtc::CritScope cs(crit_); | 57 rtc::CritScope cs(crit_); |
58 if (!enabled_) { | 58 if (!enabled_) { |
59 return; | 59 return; |
60 } | 60 } |
61 if (using_external_vad_) { | 61 if (using_external_vad_) { |
62 using_external_vad_ = false; | 62 using_external_vad_ = false; |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 RTC_DCHECK_GE(160u, audio->num_frames_per_band()); | 66 RTC_DCHECK_GE(160, audio->num_frames_per_band()); |
67 // TODO(ajm): concatenate data in frame buffer here. | 67 // TODO(ajm): concatenate data in frame buffer here. |
68 int vad_ret = WebRtcVad_Process(vad_->state(), sample_rate_hz_, | 68 int vad_ret = WebRtcVad_Process(vad_->state(), sample_rate_hz_, |
69 audio->mixed_low_pass_data(), | 69 audio->mixed_low_pass_data(), |
70 frame_size_samples_); | 70 frame_size_samples_); |
71 if (vad_ret == 0) { | 71 if (vad_ret == 0) { |
72 stream_has_voice_ = false; | 72 stream_has_voice_ = false; |
73 audio->set_activity(AudioFrame::kVadPassive); | 73 audio->set_activity(AudioFrame::kVadPassive); |
74 } else if (vad_ret == 1) { | 74 } else if (vad_ret == 1) { |
75 stream_has_voice_ = true; | 75 stream_has_voice_ = true; |
76 audio->set_activity(AudioFrame::kVadActive); | 76 audio->set_activity(AudioFrame::kVadActive); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 frame_size_ms_ = size; | 146 frame_size_ms_ = size; |
147 Initialize(sample_rate_hz_); | 147 Initialize(sample_rate_hz_); |
148 return AudioProcessing::kNoError; | 148 return AudioProcessing::kNoError; |
149 } | 149 } |
150 | 150 |
151 int VoiceDetectionImpl::frame_size_ms() const { | 151 int VoiceDetectionImpl::frame_size_ms() const { |
152 rtc::CritScope cs(crit_); | 152 rtc::CritScope cs(crit_); |
153 return frame_size_ms_; | 153 return frame_size_ms_; |
154 } | 154 } |
155 } // namespace webrtc | 155 } // namespace webrtc |
OLD | NEW |