Allow recursive check for RTC_DCHECK_RUN_ON macro
instead of using Lock/Unlock attributes, use Assert attribute to annotate code is running on certain task queue or thread.
Such check better matches what is checked, in particular allows to
recheck (and thus better document) currently used task queue
Bug: None
Change-Id: I5bc1c397efbc8342cf7915093b578bb015c85651
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269381
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37619}
diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc
index c872fe4..d6272e7 100644
--- a/pc/video_rtp_receiver.cc
+++ b/pc/video_rtp_receiver.cc
@@ -113,8 +113,8 @@
track_->internal()->set_ended();
}
-// RTC_RUN_ON(&signaling_thread_checker_)
void VideoRtpReceiver::RestartMediaChannel(absl::optional<uint32_t> ssrc) {
+ RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
MediaSourceInterface::SourceState state = source_->state();
// TODO(tommi): Can we restart the media channel without blocking?
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
@@ -124,10 +124,10 @@
source_->SetState(MediaSourceInterface::kLive);
}
-// RTC_RUN_ON(worker_thread_)
void VideoRtpReceiver::RestartMediaChannel_w(
absl::optional<uint32_t> ssrc,
MediaSourceInterface::SourceState state) {
+ RTC_DCHECK_RUN_ON(worker_thread_);
if (!media_channel_) {
return; // Can't restart.
}
@@ -166,8 +166,8 @@
}
}
-// RTC_RUN_ON(worker_thread_)
void VideoRtpReceiver::SetSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
+ RTC_DCHECK_RUN_ON(worker_thread_);
if (ssrc_) {
media_channel_->SetSink(*ssrc_, sink);
} else {
@@ -260,8 +260,8 @@
SetMediaChannel_w(media_channel);
}
-// RTC_RUN_ON(worker_thread_)
void VideoRtpReceiver::SetMediaChannel_w(cricket::MediaChannel* media_channel) {
+ RTC_DCHECK_RUN_ON(worker_thread_);
if (media_channel == media_channel_)
return;
@@ -347,8 +347,8 @@
saved_encoded_sink_enabled_ = enable;
}
-// RTC_RUN_ON(worker_thread_)
void VideoRtpReceiver::SetEncodedSinkEnabled(bool enable) {
+ RTC_DCHECK_RUN_ON(worker_thread_);
if (!media_channel_)
return;