| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 class DebugFile { | 88 class DebugFile { |
| 89 #ifdef WEBRTC_AGC_DEBUG_DUMP | 89 #ifdef WEBRTC_AGC_DEBUG_DUMP |
| 90 public: | 90 public: |
| 91 explicit DebugFile(const char* filename) | 91 explicit DebugFile(const char* filename) |
| 92 : file_(fopen(filename, "wb")) { | 92 : file_(fopen(filename, "wb")) { |
| 93 assert(file_); | 93 assert(file_); |
| 94 } | 94 } |
| 95 ~DebugFile() { | 95 ~DebugFile() { |
| 96 fclose(file_); | 96 fclose(file_); |
| 97 } | 97 } |
| 98 void Write(const int16_t* data, int length_samples) { | 98 void Write(const int16_t* data, size_t length_samples) { |
| 99 fwrite(data, 1, length_samples * sizeof(int16_t), file_); | 99 fwrite(data, 1, length_samples * sizeof(int16_t), file_); |
| 100 } | 100 } |
| 101 private: | 101 private: |
| 102 FILE* file_; | 102 FILE* file_; |
| 103 #else | 103 #else |
| 104 public: | 104 public: |
| 105 explicit DebugFile(const char* filename) { | 105 explicit DebugFile(const char* filename) { |
| 106 } | 106 } |
| 107 ~DebugFile() { | 107 ~DebugFile() { |
| 108 } | 108 } |
| 109 void Write(const int16_t* data, int length_samples) { | 109 void Write(const int16_t* data, size_t length_samples) { |
| 110 } | 110 } |
| 111 #endif // WEBRTC_AGC_DEBUG_DUMP | 111 #endif // WEBRTC_AGC_DEBUG_DUMP |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 AgcManagerDirect::AgcManagerDirect(GainControl* gctrl, | 114 AgcManagerDirect::AgcManagerDirect(GainControl* gctrl, |
| 115 VolumeCallbacks* volume_callbacks, | 115 VolumeCallbacks* volume_callbacks, |
| 116 int startup_min_level) | 116 int startup_min_level) |
| 117 : agc_(new Agc()), | 117 : agc_(new Agc()), |
| 118 gctrl_(gctrl), | 118 gctrl_(gctrl), |
| 119 volume_callbacks_(volume_callbacks), | 119 volume_callbacks_(volume_callbacks), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 181 } |
| 182 if (gctrl_->enable_limiter(true) != 0) { | 182 if (gctrl_->enable_limiter(true) != 0) { |
| 183 LOG_FERR1(LS_ERROR, enable_limiter, true); | 183 LOG_FERR1(LS_ERROR, enable_limiter, true); |
| 184 return -1; | 184 return -1; |
| 185 } | 185 } |
| 186 return 0; | 186 return 0; |
| 187 } | 187 } |
| 188 | 188 |
| 189 void AgcManagerDirect::AnalyzePreProcess(int16_t* audio, | 189 void AgcManagerDirect::AnalyzePreProcess(int16_t* audio, |
| 190 int num_channels, | 190 int num_channels, |
| 191 int samples_per_channel) { | 191 size_t samples_per_channel) { |
| 192 int length = num_channels * samples_per_channel; | 192 size_t length = num_channels * samples_per_channel; |
| 193 if (capture_muted_) { | 193 if (capture_muted_) { |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 | 196 |
| 197 file_preproc_->Write(audio, length); | 197 file_preproc_->Write(audio, length); |
| 198 | 198 |
| 199 if (frames_since_clipped_ < kClippedWaitFrames) { | 199 if (frames_since_clipped_ < kClippedWaitFrames) { |
| 200 ++frames_since_clipped_; | 200 ++frames_since_clipped_; |
| 201 return; | 201 return; |
| 202 } | 202 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 223 // will still not react until the postproc updates the level. | 223 // will still not react until the postproc updates the level. |
| 224 SetLevel(std::max(kClippedLevelMin, level_ - kClippedLevelStep)); | 224 SetLevel(std::max(kClippedLevelMin, level_ - kClippedLevelStep)); |
| 225 // Reset the AGC since the level has changed. | 225 // Reset the AGC since the level has changed. |
| 226 agc_->Reset(); | 226 agc_->Reset(); |
| 227 } | 227 } |
| 228 frames_since_clipped_ = 0; | 228 frames_since_clipped_ = 0; |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 void AgcManagerDirect::Process(const int16_t* audio, | 232 void AgcManagerDirect::Process(const int16_t* audio, |
| 233 int length, | 233 size_t length, |
| 234 int sample_rate_hz) { | 234 int sample_rate_hz) { |
| 235 if (capture_muted_) { | 235 if (capture_muted_) { |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 | 238 |
| 239 if (check_volume_on_next_process_) { | 239 if (check_volume_on_next_process_) { |
| 240 check_volume_on_next_process_ = false; | 240 check_volume_on_next_process_ = false; |
| 241 // We have to wait until the first process call to check the volume, | 241 // We have to wait until the first process call to check the volume, |
| 242 // because Chromium doesn't guarantee it to be valid any earlier. | 242 // because Chromium doesn't guarantee it to be valid any earlier. |
| 243 CheckVolumeAndReset(); | 243 CheckVolumeAndReset(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 if (new_compression != compression_) { | 433 if (new_compression != compression_) { |
| 434 compression_ = new_compression; | 434 compression_ = new_compression; |
| 435 compression_accumulator_ = new_compression; | 435 compression_accumulator_ = new_compression; |
| 436 if (gctrl_->set_compression_gain_db(compression_) != 0) { | 436 if (gctrl_->set_compression_gain_db(compression_) != 0) { |
| 437 LOG_FERR1(LS_ERROR, set_compression_gain_db, compression_); | 437 LOG_FERR1(LS_ERROR, set_compression_gain_db, compression_); |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 | 441 |
| 442 } // namespace webrtc | 442 } // namespace webrtc |
| OLD | NEW |