Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: remoting/host/audio_silence_detector.cc

Issue 1547473005: Switch to standard integer types in remoting/host/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/audio_silence_detector.h" 5 #include "remoting/host/audio_silence_detector.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 namespace remoting { 9 namespace remoting {
10 10
(...skipping 16 matching lines...) Expand all
27 AudioSilenceDetector::~AudioSilenceDetector() { 27 AudioSilenceDetector::~AudioSilenceDetector() {
28 } 28 }
29 29
30 void AudioSilenceDetector::Reset(int sampling_rate, int channels) { 30 void AudioSilenceDetector::Reset(int sampling_rate, int channels) {
31 DCHECK_GT(sampling_rate, 0); 31 DCHECK_GT(sampling_rate, 0);
32 silence_length_ = 0; 32 silence_length_ = 0;
33 silence_length_max_ = 33 silence_length_max_ =
34 sampling_rate * channels * kSilencePeriodThresholdSeconds; 34 sampling_rate * channels * kSilencePeriodThresholdSeconds;
35 } 35 }
36 36
37 bool AudioSilenceDetector::IsSilence(const int16* samples, 37 bool AudioSilenceDetector::IsSilence(const int16_t* samples,
38 size_t samples_count) { 38 size_t samples_count) {
39 bool silent_packet = true; 39 bool silent_packet = true;
40 // Potentially this loop can be optimized (e.g. using SSE or adding special 40 // Potentially this loop can be optimized (e.g. using SSE or adding special
41 // case for threshold_==0), but it's not worth worrying about because the 41 // case for threshold_==0), but it's not worth worrying about because the
42 // amount of data it processes is relaively small. 42 // amount of data it processes is relaively small.
43 for (size_t i = 0; i < samples_count; ++i) { 43 for (size_t i = 0; i < samples_count; ++i) {
44 if (abs(samples[i]) > threshold_) { 44 if (abs(samples[i]) > threshold_) {
45 silent_packet = false; 45 silent_packet = false;
46 break; 46 break;
47 } 47 }
48 } 48 }
49 49
50 if (!silent_packet) { 50 if (!silent_packet) {
51 silence_length_ = 0; 51 silence_length_ = 0;
52 return false; 52 return false;
53 } 53 }
54 54
55 silence_length_ += samples_count; 55 silence_length_ += samples_count;
56 return silence_length_ > silence_length_max_; 56 return silence_length_ > silence_length_max_;
57 } 57 }
58 58
59 } // namespace remoting 59 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/audio_silence_detector.h ('k') | remoting/host/audio_silence_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698