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

Unified Diff: webrtc/modules/audio_device/include/fake_audio_device.h

Issue 2710023010: Fix busy loop in FakeAudioDeviceModule. (Closed)
Patch Set: Add some logic to reduce callbacks when appropriate Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/include/fake_audio_device.h
diff --git a/webrtc/modules/audio_device/include/fake_audio_device.h b/webrtc/modules/audio_device/include/fake_audio_device.h
index a28ad8646436eaaec4f2a7bb016c927e5cc3d7ab..1797dd5e8db9b5cc978075a62f907e257324f8d2 100644
--- a/webrtc/modules/audio_device/include/fake_audio_device.h
+++ b/webrtc/modules/audio_device/include/fake_audio_device.h
@@ -41,8 +41,20 @@ class FakeAudioDeviceModule : public AudioDeviceModule {
virtual int32_t SetStereoRecording(bool enable) { return 0; }
virtual int32_t SetAGC(bool enable) { return 0; }
virtual int32_t StopRecording() { return 0; }
- virtual int64_t TimeUntilNextProcess() { return 0; }
- virtual void Process() {}
+
+ // If the subclass doesn't override the ProcessThread implementation,
+ // we'll fall back on an implementation that doesn't eat too much CPU.
+ virtual int64_t TimeUntilNextProcess() {
+ if (turn_off_module_callbacks_)
the sun 2017/02/25 20:01:07 return time_until_next_process_;
+ return 7 * 24 * 60 * 60 * 1000; // call me next week.
+ uses_default_module_implementation_ = true;
+ return 10;
+ }
+
+ virtual void Process() {
+ turn_off_module_callbacks_ = uses_default_module_implementation_;
the sun 2017/02/25 20:01:07 // After first call to Process(), we wait a long t
+ }
+
virtual int32_t Terminate() { return 0; }
virtual int32_t ActiveAudioLayer(AudioLayer* audioLayer) const { return 0; }
@@ -167,6 +179,10 @@ class FakeAudioDeviceModule : public AudioDeviceModule {
return -1;
}
#endif // WEBRTC_IOS
+
+ private:
+ bool uses_default_module_implementation_ = false;
the sun 2017/02/25 20:01:07 int64_t time_until_next_process_ = 10;
+ bool turn_off_module_callbacks_ = false;
};
} // namespace webrtc
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698