APM: Make the GetStatistics call independent of the locks in APM
This CL changes the GetStatistics call in the audio processing module
(APM) to not aquire the render or capture locks in APM, while still
being thread-safe.
This change eliminates the risk of thread-priority inversion due to the
GetStatistics call.
Apart from the above the CL:
-Corrects the GetStatistics to not be const (it was const even though it
aquired locks).
-Slightly changes the statistics reporting, so that the stats received
may be older than the most recent stats reported.
Bug: webrtc:11241
Change-Id: I00deb5507e004cbe6e4a19a8bad357491f86f4ab
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/163982
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30131}
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index 3d278cd..c7fc1c4 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -631,12 +631,14 @@
// TODO(peah): Remove this method.
virtual void UpdateHistogramsOnCallEnd() = 0;
- // Get audio processing statistics. The |has_remote_tracks| argument should be
- // set if there are active remote tracks (this would usually be true during
- // a call). If there are no remote tracks some of the stats will not be set by
- // AudioProcessing, because they only make sense if there is at least one
- // remote track.
- virtual AudioProcessingStats GetStatistics(bool has_remote_tracks) const = 0;
+ // Get audio processing statistics.
+ virtual AudioProcessingStats GetStatistics() = 0;
+ // TODO(webrtc:5298) Deprecated variant. The |has_remote_tracks| argument
+ // should be set if there are active remote tracks (this would usually be true
+ // during a call). If there are no remote tracks some of the stats will not be
+ // set by AudioProcessing, because they only make sense if there is at least
+ // one remote track.
+ virtual AudioProcessingStats GetStatistics(bool has_remote_tracks) = 0;
// Returns the last applied configuration.
virtual AudioProcessing::Config GetConfig() const = 0;