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