Commit 884edb78 authored by John Rummell's avatar John Rummell Committed by Commit Bot

Add GUARDED_BY annotations to //media/blink.

Adding the annotation makes it clear which fields are protected by
base::Lock, and enables compile-time analysis to verify this.

BUG=893739,887645
TEST=compiles

Change-Id: Ibf8ff9b73f218fcd3cfeb4387e7ad406418ef522
Reviewed-on: https://chromium-review.googlesource.com/c/1303405Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604802}
parent be707070
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/thread_annotations.h"
#include "base/time/tick_clock.h" #include "base/time/tick_clock.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
...@@ -144,8 +145,6 @@ class MEDIA_BLINK_EXPORT VideoFrameCompositor : public VideoRendererSink, ...@@ -144,8 +145,6 @@ class MEDIA_BLINK_EXPORT VideoFrameCompositor : public VideoRendererSink,
tick_clock_ = tick_clock; tick_clock_ = tick_clock;
} }
void clear_current_frame_for_testing() { current_frame_ = nullptr; }
// Enables or disables background rendering. If |enabled|, |timeout| is the // Enables or disables background rendering. If |enabled|, |timeout| is the
// amount of time to wait after the last Render() call before starting the // amount of time to wait after the last Render() call before starting the
// background rendering mode. Note, this can not disable the background // background rendering mode. Note, this can not disable the background
...@@ -218,13 +217,14 @@ class MEDIA_BLINK_EXPORT VideoFrameCompositor : public VideoRendererSink, ...@@ -218,13 +217,14 @@ class MEDIA_BLINK_EXPORT VideoFrameCompositor : public VideoRendererSink,
OnNewProcessedFrameCB new_processed_frame_cb_; OnNewProcessedFrameCB new_processed_frame_cb_;
cc::UpdateSubmissionStateCB update_submission_state_callback_; cc::UpdateSubmissionStateCB update_submission_state_callback_;
// Set on the compositor thread, but also read on the media thread. // Set on the compositor thread, but also read on the media thread. Lock is
// not used when reading |current_frame_| on the compositor thread.
base::Lock current_frame_lock_; base::Lock current_frame_lock_;
scoped_refptr<VideoFrame> current_frame_; scoped_refptr<VideoFrame> current_frame_;
// These values are updated and read from the media and compositor threads. // These values are updated and read from the media and compositor threads.
base::Lock callback_lock_; base::Lock callback_lock_;
VideoRendererSink::RenderCallback* callback_; VideoRendererSink::RenderCallback* callback_ GUARDED_BY(callback_lock_);
// AutoOpenCloseEvent for begin/end events. // AutoOpenCloseEvent for begin/end events.
std::unique_ptr<base::trace_event::AutoOpenCloseEvent> auto_open_close_; std::unique_ptr<base::trace_event::AutoOpenCloseEvent> auto_open_close_;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/thread_annotations.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "media/audio/null_audio_sink.h" #include "media/audio/null_audio_sink.h"
#include "media/base/audio_timestamp_helper.h" #include "media/base/audio_timestamp_helper.h"
...@@ -101,7 +102,7 @@ class WebAudioSourceProviderImpl::TeeFilter ...@@ -101,7 +102,7 @@ class WebAudioSourceProviderImpl::TeeFilter
// acquire a lock to read |copy_audio_bus_callback_| when necessary. // acquire a lock to read |copy_audio_bus_callback_| when necessary.
std::atomic<bool> copy_required_; std::atomic<bool> copy_required_;
base::Lock copy_lock_; base::Lock copy_lock_;
CopyAudioCB copy_audio_bus_callback_; CopyAudioCB copy_audio_bus_callback_ GUARDED_BY(copy_lock_);
DISALLOW_COPY_AND_ASSIGN(TeeFilter); DISALLOW_COPY_AND_ASSIGN(TeeFilter);
}; };
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/thread_annotations.h"
#include "media/base/audio_renderer_sink.h" #include "media/base/audio_renderer_sink.h"
#include "media/blink/media_blink_export.h" #include "media/blink/media_blink_export.h"
#include "third_party/blink/public/platform/web_audio_source_provider.h" #include "third_party/blink/public/platform/web_audio_source_provider.h"
...@@ -101,7 +102,7 @@ class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl ...@@ -101,7 +102,7 @@ class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl
// Where audio ends up unless overridden by |client_|. // Where audio ends up unless overridden by |client_|.
base::Lock sink_lock_; base::Lock sink_lock_;
scoped_refptr<SwitchableAudioRendererSink> sink_; scoped_refptr<SwitchableAudioRendererSink> sink_ GUARDED_BY(sink_lock_);
std::unique_ptr<AudioBus> bus_wrapper_; std::unique_ptr<AudioBus> bus_wrapper_;
// An inner class acting as a T filter where actual data can be tapped. // An inner class acting as a T filter where actual data can be tapped.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment