Fix occasional race in VideoCapturerTrackSource seen by memcheck bot.
The issue was that VideoCapturerTrackSource was adding a reference to itself, causing it to not be deleted even after no external objects reference it. The objects underneath it (threads for instance) may then be destroyed before the object dereferences them. BUG=webrtc:6487 Review-Url: https://codereview.webrtc.org/2717023002 Cr-Commit-Position: refs/heads/master@{#16841}
This commit is contained in:
parent
ccaaffb44a
commit
f15fb452ef
@ -382,10 +382,14 @@ void VideoCapturerTrackSource::OnStateChange(
|
||||
cricket::VideoCapturer* capturer,
|
||||
cricket::CaptureState capture_state) {
|
||||
if (rtc::Thread::Current() != signaling_thread_) {
|
||||
// Use rtc::Unretained, because we don't want this to capture a reference
|
||||
// to ourselves. If our destructor is called while this task is executing,
|
||||
// that's fine; our AsyncInvoker destructor will wait for it to finish if
|
||||
// it isn't simply canceled.
|
||||
invoker_.AsyncInvoke<void>(
|
||||
RTC_FROM_HERE, signaling_thread_,
|
||||
rtc::Bind(&VideoCapturerTrackSource::OnStateChange, this, capturer,
|
||||
capture_state));
|
||||
rtc::Bind(&VideoCapturerTrackSource::OnStateChange,
|
||||
rtc::Unretained(this), capturer, capture_state));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -47,14 +47,10 @@ class VideoCapturerTrackSource : public VideoTrackSource,
|
||||
std::unique_ptr<cricket::VideoCapturer> capturer,
|
||||
bool remote);
|
||||
|
||||
bool is_screencast() const override {
|
||||
return video_capturer_->IsScreencast();
|
||||
}
|
||||
rtc::Optional<bool> needs_denoising() const override {
|
||||
return needs_denoising_;
|
||||
}
|
||||
bool is_screencast() const final { return video_capturer_->IsScreencast(); }
|
||||
rtc::Optional<bool> needs_denoising() const final { return needs_denoising_; }
|
||||
|
||||
bool GetStats(Stats* stats) override;
|
||||
bool GetStats(Stats* stats) final;
|
||||
|
||||
protected:
|
||||
VideoCapturerTrackSource(rtc::Thread* worker_thread,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user