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}
This commit is contained in:
Gary Kacmarcik
2019-01-11 09:29:19 -08:00
committed by Commit Bot
parent b46235c1cc
commit 2bb29f018a
3 changed files with 3 additions and 2 deletions

View File

@ -32,8 +32,8 @@ BlankDetectorDesktopCapturerWrapper::~BlankDetectorDesktopCapturerWrapper() =
void BlankDetectorDesktopCapturerWrapper::Start(
DesktopCapturer::Callback* callback) {
capturer_->Start(this);
callback_ = callback;
capturer_->Start(this);
}
void BlankDetectorDesktopCapturerWrapper::SetSharedMemoryFactory(

View File

@ -30,6 +30,7 @@ CaptureResultDesktopCapturerWrapper::~CaptureResultDesktopCapturerWrapper() =
void CaptureResultDesktopCapturerWrapper::Start(Callback* callback) {
if ((callback_ == nullptr) != (callback == nullptr)) {
if (callback) {
callback_ = callback;
base_capturer_->Start(this);
} else {
base_capturer_->Start(nullptr);

View File

@ -80,6 +80,7 @@ FallbackDesktopCapturerWrapper::~FallbackDesktopCapturerWrapper() = default;
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 @@ void FallbackDesktopCapturerWrapper::Start(
// 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(