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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void UpdatePlayoutParameters(); | 79 void UpdatePlayoutParameters(); |
80 void UpdateRecordingParameters(); | 80 void UpdateRecordingParameters(); |
81 | 81 |
82 // Posts the first delayed task in the task queue and starts the periodic | 82 // Posts the first delayed task in the task queue and starts the periodic |
83 // timer. | 83 // timer. |
84 void StartTimer(); | 84 void StartTimer(); |
85 | 85 |
86 // Called periodically on the internal thread created by the TaskQueue. | 86 // Called periodically on the internal thread created by the TaskQueue. |
87 void LogStats(); | 87 void LogStats(); |
88 | 88 |
| 89 // Clears all members tracking stats for recording and playout. |
| 90 void ResetRecStats(); |
| 91 void ResetPlayStats(); |
| 92 |
89 // Updates counters in each play/record callback but does it on the task | 93 // Updates counters in each play/record callback but does it on the task |
90 // queue to ensure that they can be read by LogStats() without any locks since | 94 // queue to ensure that they can be read by LogStats() without any locks since |
91 // each task is serialized by the task queue. | 95 // each task is serialized by the task queue. |
92 void UpdateRecStats(size_t num_samples); | 96 void UpdateRecStats(const void* audio_buffer, size_t num_samples); |
93 void UpdatePlayStats(size_t num_samples); | 97 void UpdatePlayStats(const void* audio_buffer, size_t num_samples); |
94 | 98 |
95 // Ensures that methods are called on the same thread as the thread that | 99 // Ensures that methods are called on the same thread as the thread that |
96 // creates this object. | 100 // creates this object. |
97 rtc::ThreadChecker thread_checker_; | 101 rtc::ThreadChecker thread_checker_; |
98 | 102 |
99 // Raw pointer to AudioTransport instance. Supplied to RegisterAudioCallback() | 103 // Raw pointer to AudioTransport instance. Supplied to RegisterAudioCallback() |
100 // and it must outlive this object. | 104 // and it must outlive this object. |
101 AudioTransport* audio_transport_cb_; | 105 AudioTransport* audio_transport_cb_; |
102 | 106 |
103 // TODO(henrika): given usage of thread checker, it should be possible to | 107 // TODO(henrika): given usage of thread checker, it should be possible to |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 196 |
193 // Time stamp of last playout callback. | 197 // Time stamp of last playout callback. |
194 uint64_t last_playout_time_; | 198 uint64_t last_playout_time_; |
195 | 199 |
196 // An array where the position corresponds to time differences (in | 200 // An array where the position corresponds to time differences (in |
197 // milliseconds) between two successive playout callbacks, and the stored | 201 // milliseconds) between two successive playout callbacks, and the stored |
198 // value is the number of times a given time difference was found. | 202 // value is the number of times a given time difference was found. |
199 // Writing to the array is done without a lock since it is only read once at | 203 // Writing to the array is done without a lock since it is only read once at |
200 // destruction when no audio is running. | 204 // destruction when no audio is running. |
201 uint32_t playout_diff_times_[kMaxDeltaTimeInMs + 1] = {0}; | 205 uint32_t playout_diff_times_[kMaxDeltaTimeInMs + 1] = {0}; |
| 206 |
| 207 // Contains max level (max(abs(x))) of recorded audio packets over the last |
| 208 // 10 seconds where a new measurement is done twice per second. The level |
| 209 // is reset to zero at each call to LogStats(). Only modified on the task |
| 210 // queue thread. |
| 211 int16_t max_rec_level_; |
| 212 |
| 213 // Contains max level of recorded audio packets over the last 10 seconds |
| 214 // where a new measurement is done twice per second. |
| 215 int16_t max_play_level_; |
| 216 |
| 217 // Counts number of times we detect "no audio" corresponding to a case where |
| 218 // all level measurements since the last log has been exactly zero. |
| 219 // In other words: this counter is incremented only if 20 measurements |
| 220 // (two per second) in a row equals zero. The member is only incremented on |
| 221 // the task queue and max once every 10th second. |
| 222 size_t num_rec_level_is_zero_; |
202 }; | 223 }; |
203 | 224 |
204 } // namespace webrtc | 225 } // namespace webrtc |
205 | 226 |
206 #endif // WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ | 227 #endif // WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ |
OLD | NEW |