Chromium Code Reviews| Index: webrtc/modules/audio_device/audio_device_buffer.h |
| diff --git a/webrtc/modules/audio_device/audio_device_buffer.h b/webrtc/modules/audio_device/audio_device_buffer.h |
| index e2c6f2871a5fad2f0443ca878c979bddfe2bd899..0ffb736de579ef71ad70fc2550a300ef0cc3bc2c 100644 |
| --- a/webrtc/modules/audio_device/audio_device_buffer.h |
| +++ b/webrtc/modules/audio_device/audio_device_buffer.h |
| @@ -12,6 +12,7 @@ |
| #define WEBRTC_MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ |
| #include "webrtc/base/buffer.h" |
| +#include "webrtc/base/criticalsection.h" |
| #include "webrtc/base/task_queue.h" |
| #include "webrtc/base/thread_annotations.h" |
| #include "webrtc/base/thread_checker.h" |
| @@ -92,9 +93,8 @@ class AudioDeviceBuffer { |
| // state = LOG_ACTIVE => logs are printed and the timer is kept alive. |
| void LogStats(LogState state); |
| - // Updates counters in each play/record callback but does it on the task |
| - // queue to ensure that they can be read by LogStats() without any locks since |
| - // each task is serialized by the task queue. |
| + // Updates counters in each play/record callback. These counters are later |
| + // (periodically) read by LogStats() using a lock. |
| void UpdateRecStats(int16_t max_abs, size_t samples_per_channel); |
| void UpdatePlayStats(int16_t max_abs, size_t samples_per_channel); |
| @@ -120,6 +120,8 @@ class AudioDeviceBuffer { |
| // Native (platform specific) audio thread driving the recording side. |
| rtc::ThreadChecker recording_thread_checker_; |
| + rtc::CriticalSection lock_; |
| + |
| // Task queue used to invoke LogStats() periodically. Tasks are executed on a |
| // worker thread but it does not necessarily have to be the same thread for |
| // each task. |
| @@ -184,41 +186,18 @@ class AudioDeviceBuffer { |
| // Counts number of times LogStats() has been called. |
| size_t num_stat_reports_ ACCESS_ON(task_queue_); |
| - // Total number of recording callbacks where the source provides 10ms audio |
| - // data each time. |
| - uint64_t rec_callbacks_ ACCESS_ON(task_queue_); |
| - |
| // Total number of recording callbacks stored at the last timer task. |
| uint64_t last_rec_callbacks_ ACCESS_ON(task_queue_); |
|
the sun
2017/02/01 22:37:42
Put these 4 stats in an internal Stats struct to a
henrika_webrtc
2017/02/02 13:51:48
Acknowledged.
|
| - // Total number of playback callbacks where the sink asks for 10ms audio |
| - // data each time. |
| - uint64_t play_callbacks_ ACCESS_ON(task_queue_); |
| - |
| // Total number of playout callbacks stored at the last timer task. |
| uint64_t last_play_callbacks_ ACCESS_ON(task_queue_); |
| - // Total number of recorded audio samples. |
| - uint64_t rec_samples_ ACCESS_ON(task_queue_); |
| - |
| // Total number of recorded samples stored at the previous timer task. |
| uint64_t last_rec_samples_ ACCESS_ON(task_queue_); |
| - // Total number of played audio samples. |
| - uint64_t play_samples_ ACCESS_ON(task_queue_); |
| - |
| // Total number of played samples stored at the previous timer task. |
| uint64_t last_play_samples_ ACCESS_ON(task_queue_); |
| - // Contains max level (max(abs(x))) of recorded audio packets over the last |
| - // 10 seconds where a new measurement is done twice per second. The level |
| - // is reset to zero at each call to LogStats(). |
| - int16_t max_rec_level_ ACCESS_ON(task_queue_); |
| - |
| - // Contains max level of recorded audio packets over the last 10 seconds |
| - // where a new measurement is done twice per second. |
| - int16_t max_play_level_ ACCESS_ON(task_queue_); |
| - |
| // Time stamp of last timer task (drives logging). |
| int64_t last_timer_task_time_ ACCESS_ON(task_queue_); |
| @@ -231,6 +210,29 @@ class AudioDeviceBuffer { |
| int64_t play_start_time_ ACCESS_ON(main_thread_checker_); |
| int64_t rec_start_time_ ACCESS_ON(main_thread_checker_); |
| + // Total number of recording callbacks where the source provides 10ms audio |
| + // data each time. |
| + uint64_t rec_callbacks_ GUARDED_BY(lock_); |
| + |
| + // Total number of playback callbacks where the sink asks for 10ms audio |
| + // data each time. |
| + uint64_t play_callbacks_ GUARDED_BY(lock_); |
| + |
| + // Total number of recorded audio samples. |
| + uint64_t rec_samples_ GUARDED_BY(lock_); |
| + |
| + // Total number of played audio samples. |
| + uint64_t play_samples_ GUARDED_BY(lock_); |
| + |
| + // Contains max level (max(abs(x))) of recorded audio packets over the last |
| + // 10 seconds where a new measurement is done twice per second. The level |
| + // is reset to zero at each call to LogStats(). |
| + int16_t max_rec_level_ GUARDED_BY(lock_); |
| + |
| + // Contains max level of recorded audio packets over the last 10 seconds |
| + // where a new measurement is done twice per second. |
| + int16_t max_play_level_ GUARDED_BY(lock_); |
| + |
| // Set to true at construction and modified to false as soon as one audio- |
| // level estimate larger than zero is detected. |
| bool only_silence_recorded_; |