Set callback_ member at start of desktop capturer Start()
Some callback wrappers set the callback_ member at the start, but
most set it after calling any owned implementation of Start().
Setting it after the call means that the callback_ is not set up
for any callbacks that happen during the call.
This cl fixes that by setting the callback_ member before any
calls are made in Start().
Bug: chromium:916961
Change-Id: Id26f8cc98377ef217f928095834162f5526c1fdf
Reviewed-on: https://webrtc-review.googlesource.com/c/117040
Reviewed-by: Brave Yao <braveyao@webrtc.org>
Commit-Queue: Gary Kacmarcik <garykac@chromium.org>
Cr-Commit-Position: refs/heads/master@{#26231}
diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc
index 061aab0..cf2d03d 100644
--- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc
+++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc
@@ -32,8 +32,8 @@
void BlankDetectorDesktopCapturerWrapper::Start(
DesktopCapturer::Callback* callback) {
- capturer_->Start(this);
callback_ = callback;
+ capturer_->Start(this);
}
void BlankDetectorDesktopCapturerWrapper::SetSharedMemoryFactory(
diff --git a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc
index 5e0d264..e1d4b99 100644
--- a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc
+++ b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc
@@ -30,6 +30,7 @@
void CaptureResultDesktopCapturerWrapper::Start(Callback* callback) {
if ((callback_ == nullptr) != (callback == nullptr)) {
if (callback) {
+ callback_ = callback;
base_capturer_->Start(this);
} else {
base_capturer_->Start(nullptr);
diff --git a/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc b/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
index 5f60f1e..48ee6e2 100644
--- a/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
+++ b/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
@@ -80,6 +80,7 @@
void FallbackDesktopCapturerWrapper::Start(
DesktopCapturer::Callback* callback) {
+ callback_ = callback;
// FallbackDesktopCapturerWrapper catchs the callback of the main capturer,
// and checks its return value to decide whether the secondary capturer should
// be involved.
@@ -88,7 +89,6 @@
// FallbackDesktopCapturerWrapper won't check its return value any more. It
// will directly return to the input |callback|.
secondary_capturer_->Start(callback);
- callback_ = callback;
}
void FallbackDesktopCapturerWrapper::SetSharedMemoryFactory(