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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 _renderDelayOffsetSamples(0), | 142 _renderDelayOffsetSamples(0), |
143 _playBufDelayFixed(20), | 143 _playBufDelayFixed(20), |
144 _playWarning(0), | 144 _playWarning(0), |
145 _playError(0), | 145 _playError(0), |
146 _recWarning(0), | 146 _recWarning(0), |
147 _recError(0), | 147 _recError(0), |
148 _paCaptureBuffer(NULL), | 148 _paCaptureBuffer(NULL), |
149 _paRenderBuffer(NULL), | 149 _paRenderBuffer(NULL), |
150 _captureBufSizeSamples(0), | 150 _captureBufSizeSamples(0), |
151 _renderBufSizeSamples(0), | 151 _renderBufSizeSamples(0), |
152 prev_key_state_() | 152 prev_key_state_(), |
153 get_mic_volume_counter_ms_(0) | |
153 { | 154 { |
154 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, | 155 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, |
155 "%s created", __FUNCTION__); | 156 "%s created", __FUNCTION__); |
156 | 157 |
157 RTC_DCHECK(&_stopEvent != NULL); | 158 RTC_DCHECK(&_stopEvent != NULL); |
158 RTC_DCHECK(&_stopEventRec != NULL); | 159 RTC_DCHECK(&_stopEventRec != NULL); |
159 | 160 |
160 memset(_renderConvertData, 0, sizeof(_renderConvertData)); | 161 memset(_renderConvertData, 0, sizeof(_renderConvertData)); |
161 memset(&_outStreamFormat, 0, sizeof(AudioStreamBasicDescription)); | 162 memset(&_outStreamFormat, 0, sizeof(AudioStreamBasicDescription)); |
162 memset(&_outDesiredFormat, 0, sizeof(AudioStreamBasicDescription)); | 163 memset(&_outDesiredFormat, 0, sizeof(AudioStreamBasicDescription)); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 { | 373 { |
373 _macBookPro = true; | 374 _macBookPro = true; |
374 } | 375 } |
375 } | 376 } |
376 | 377 |
377 _playWarning = 0; | 378 _playWarning = 0; |
378 _playError = 0; | 379 _playError = 0; |
379 _recWarning = 0; | 380 _recWarning = 0; |
380 _recError = 0; | 381 _recError = 0; |
381 | 382 |
383 get_mic_volume_counter_ms_ = 0; | |
384 | |
382 _initialized = true; | 385 _initialized = true; |
383 | 386 |
384 return 0; | 387 return 0; |
385 } | 388 } |
386 | 389 |
387 int32_t AudioDeviceMac::Terminate() | 390 int32_t AudioDeviceMac::Terminate() |
388 { | 391 { |
389 | 392 |
390 if (!_initialized) | 393 if (!_initialized) |
391 { | 394 { |
(...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3174 return false; | 3177 return false; |
3175 } | 3178 } |
3176 | 3179 |
3177 // store the recorded buffer (no action will be taken if the | 3180 // store the recorded buffer (no action will be taken if the |
3178 // #recorded samples is not a full buffer) | 3181 // #recorded samples is not a full buffer) |
3179 _ptrAudioBuffer->SetRecordedBuffer((int8_t*) &recordBuffer, | 3182 _ptrAudioBuffer->SetRecordedBuffer((int8_t*) &recordBuffer, |
3180 (uint32_t) size); | 3183 (uint32_t) size); |
3181 | 3184 |
3182 if (AGC()) | 3185 if (AGC()) |
3183 { | 3186 { |
3184 // store current mic level in the audio buffer if AGC is enabled | 3187 // Use mod to ensure we check the volume on the first pass. |
henrika_webrtc
2016/01/08 08:14:42
Out indentation kind of sucks but I guess we shoul
Andrew MacDonald
2016/01/08 08:22:09
:)
I can run clang-format on these files in a fol
| |
3185 if (MicrophoneVolume(currentMicLevel) == 0) | 3188 if (get_mic_volume_counter_ms_ % kGetMicVolumeIntervalMs == 0) { |
3186 { | 3189 get_mic_volume_counter_ms_ = 0; |
3187 // this call does not affect the actual microphone volume | 3190 // store current mic level in the audio buffer if AGC is enabled |
3188 _ptrAudioBuffer->SetCurrentMicLevel(currentMicLevel); | 3191 if (MicrophoneVolume(currentMicLevel) == 0) |
3192 { | |
3193 // this call does not affect the actual microphone volume | |
3194 _ptrAudioBuffer->SetCurrentMicLevel(currentMicLevel); | |
3195 } | |
3189 } | 3196 } |
3197 get_mic_volume_counter_ms_ += kBufferSizeMs; | |
3190 } | 3198 } |
3191 | 3199 |
3192 _ptrAudioBuffer->SetVQEData(msecOnPlaySide, msecOnRecordSide, 0); | 3200 _ptrAudioBuffer->SetVQEData(msecOnPlaySide, msecOnRecordSide, 0); |
3193 | 3201 |
3194 _ptrAudioBuffer->SetTypingStatus(KeyPressed()); | 3202 _ptrAudioBuffer->SetTypingStatus(KeyPressed()); |
3195 | 3203 |
3196 // deliver recorded samples at specified sample rate, mic level etc. | 3204 // deliver recorded samples at specified sample rate, mic level etc. |
3197 // to the observer using callback | 3205 // to the observer using callback |
3198 _ptrAudioBuffer->DeliverRecordedData(); | 3206 _ptrAudioBuffer->DeliverRecordedData(); |
3199 | 3207 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3232 kCGEventSourceStateHIDSystemState, | 3240 kCGEventSourceStateHIDSystemState, |
3233 key_index); | 3241 key_index); |
3234 // A false -> true change in keymap means a key is pressed. | 3242 // A false -> true change in keymap means a key is pressed. |
3235 key_down |= (keyState && !prev_key_state_[key_index]); | 3243 key_down |= (keyState && !prev_key_state_[key_index]); |
3236 // Save current state. | 3244 // Save current state. |
3237 prev_key_state_[key_index] = keyState; | 3245 prev_key_state_[key_index] = keyState; |
3238 } | 3246 } |
3239 return key_down; | 3247 return key_down; |
3240 } | 3248 } |
3241 } // namespace webrtc | 3249 } // namespace webrtc |
OLD | NEW |