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

Unified Diff: webrtc/video/video_receive_stream.cc

Issue 2402663003: Avoid race in VideoReceiveStream shutdown (Closed)
Patch Set: Created 4 years, 2 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/video/video_receive_stream.cc
diff --git a/webrtc/video/video_receive_stream.cc b/webrtc/video/video_receive_stream.cc
index 2b4a3c2b7b0f131a662255a33af24f69dfc4c0aa..7d77751db3cd8c69c6d3b9f51f92ee96e69e9b3a 100644
--- a/webrtc/video/video_receive_stream.cc
+++ b/webrtc/video/video_receive_stream.cc
@@ -246,13 +246,6 @@ VideoReceiveStream::~VideoReceiveStream() {
process_thread_->DeRegisterModule(&rtp_stream_sync_);
process_thread_->DeRegisterModule(&video_receiver_);
- // Deregister external decoders so they are no longer running during
- // destruction. This effectively stops the VCM since the decoder thread is
- // stopped, the VCM is deregistered and no asynchronous decoder threads are
- // running.
- for (const Decoder& decoder : config_.decoders)
- video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type);
-
congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_))
->RemoveStream(rtp_stream_receiver_.GetRemoteSsrc());
}
@@ -307,7 +300,15 @@ void VideoReceiveStream::Stop() {
// stop immediately, instead of waiting for a timeout. Needs to be called
// before joining the decoder thread thread.
video_receiver_.TriggerDecoderShutdown();
- decode_thread_.Stop();
+ if (decode_thread_.IsRunning()) {
+ decode_thread_.Stop();
+ // Deregister external decoders so they are no longer running during
+ // destruction. This effectively stops the VCM since the decoder thread is
+ // stopped, the VCM is deregistered and no asynchronous decoder threads are
+ // running.
+ for (const Decoder& decoder : config_.decoders)
+ video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type);
+ }
call_stats_->DeregisterStatsObserver(video_stream_decoder_.get());
video_stream_decoder_.reset();
incoming_video_stream_.reset();
« 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