| Index: remoting/host/audio_silence_detector.cc
|
| diff --git a/remoting/host/audio_silence_detector.cc b/remoting/host/audio_silence_detector.cc
|
| index a744b35a117f5772be80ff8435f1a5c9ac7388ff..9f125458f4236a0074e06648a9675e039ebac9ed 100644
|
| --- a/remoting/host/audio_silence_detector.cc
|
| +++ b/remoting/host/audio_silence_detector.cc
|
| @@ -20,7 +20,8 @@ int kSilencePeriodThresholdSeconds = 1;
|
| AudioSilenceDetector::AudioSilenceDetector(int threshold)
|
| : threshold_(threshold),
|
| silence_length_max_(0),
|
| - silence_length_(0) {
|
| + silence_length_(0),
|
| + channels_(0) {
|
| DCHECK_GE(threshold_, 0);
|
| }
|
|
|
| @@ -29,18 +30,21 @@ AudioSilenceDetector::~AudioSilenceDetector() {
|
|
|
| void AudioSilenceDetector::Reset(int sampling_rate, int channels) {
|
| DCHECK_GT(sampling_rate, 0);
|
| + DCHECK_GT(channels, 0);
|
| silence_length_ = 0;
|
| silence_length_max_ =
|
| sampling_rate * channels * kSilencePeriodThresholdSeconds;
|
| + channels_ = channels;
|
| }
|
|
|
| bool AudioSilenceDetector::IsSilence(const int16_t* samples,
|
| - size_t samples_count) {
|
| + size_t frames) {
|
| + const int samples_count = frames * channels();
|
| bool silent_packet = true;
|
| // Potentially this loop can be optimized (e.g. using SSE or adding special
|
| // case for threshold_==0), but it's not worth worrying about because the
|
| // amount of data it processes is relaively small.
|
| - for (size_t i = 0; i < samples_count; ++i) {
|
| + for (int i = 0; i < samples_count; ++i) {
|
| if (abs(samples[i]) > threshold_) {
|
| silent_packet = false;
|
| break;
|
| @@ -56,4 +60,8 @@ bool AudioSilenceDetector::IsSilence(const int16_t* samples,
|
| return silence_length_ > silence_length_max_;
|
| }
|
|
|
| +int AudioSilenceDetector::channels() const {
|
| + return channels_;
|
| +}
|
| +
|
| } // namespace remoting
|
|
|