diff options
author | Markus Handell <handellm@webrtc.org> | 2020-07-09 01:34:42 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-10 08:27:45 +0000 |
commit | f7303e64864f875ac710edaed3f318fe2a635fe9 (patch) | |
tree | f3eeb0a98fb387c14930e989fa4c62fb2c0666d8 /media | |
parent | 85585f4a523ef626ec23d5293e96123468b0aee9 (diff) | |
download | webrtc-f7303e64864f875ac710edaed3f318fe2a635fe9.tar.gz |
Migrate leftovers in media/ and modules/ to webrtc::Mutex.
Bug: webrtc:11567
Change-Id: Id40a53fcec6cba1cd5af70422291ba46b0a6da8c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178905
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31694}
Diffstat (limited to 'media')
-rw-r--r-- | media/base/video_adapter.cc | 6 | ||||
-rw-r--r-- | media/base/video_adapter.h | 58 |
2 files changed, 28 insertions, 36 deletions
diff --git a/media/base/video_adapter.cc b/media/base/video_adapter.cc index 8ba91d7189..73e77cc37e 100644 --- a/media/base/video_adapter.cc +++ b/media/base/video_adapter.cc @@ -190,7 +190,7 @@ bool VideoAdapter::AdaptFrameResolution(int in_width, int* cropped_height, int* out_width, int* out_height) { - rtc::CritScope cs(&critical_section_); + webrtc::MutexLock lock(&mutex_); ++frames_in_; // The max output pixel count is the minimum of the requests from @@ -329,7 +329,7 @@ void VideoAdapter::OnOutputFormatRequest( const absl::optional<std::pair<int, int>>& target_portrait_aspect_ratio, const absl::optional<int>& max_portrait_pixel_count, const absl::optional<int>& max_fps) { - rtc::CritScope cs(&critical_section_); + webrtc::MutexLock lock(&mutex_); target_landscape_aspect_ratio_ = target_landscape_aspect_ratio; max_landscape_pixel_count_ = max_landscape_pixel_count; target_portrait_aspect_ratio_ = target_portrait_aspect_ratio; @@ -339,7 +339,7 @@ void VideoAdapter::OnOutputFormatRequest( } void VideoAdapter::OnSinkWants(const rtc::VideoSinkWants& sink_wants) { - rtc::CritScope cs(&critical_section_); + webrtc::MutexLock lock(&mutex_); resolution_request_max_pixel_count_ = sink_wants.max_pixel_count; resolution_request_target_pixel_count_ = sink_wants.target_pixel_count.value_or( diff --git a/media/base/video_adapter.h b/media/base/video_adapter.h index b7acf0e67c..2c42632762 100644 --- a/media/base/video_adapter.h +++ b/media/base/video_adapter.h @@ -19,7 +19,7 @@ #include "api/video/video_source_interface.h" #include "media/base/video_common.h" #include "rtc_base/constructor_magic.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" namespace cricket { @@ -46,8 +46,7 @@ class VideoAdapter { int* cropped_width, int* cropped_height, int* out_width, - int* out_height) - RTC_LOCKS_EXCLUDED(critical_section_); + int* out_height) RTC_LOCKS_EXCLUDED(mutex_); // DEPRECATED. Please use OnOutputFormatRequest below. // TODO(asapersson): Remove this once it is no longer used. @@ -59,7 +58,7 @@ class VideoAdapter { // 720x1280 is requested. // Note: Should be called from the source only. void OnOutputFormatRequest(const absl::optional<VideoFormat>& format) - RTC_LOCKS_EXCLUDED(critical_section_); + RTC_LOCKS_EXCLUDED(mutex_); // Requests output frame size and frame interval from |AdaptFrameResolution|. // |target_aspect_ratio|: The input frame size will be cropped to match the @@ -72,7 +71,7 @@ class VideoAdapter { void OnOutputFormatRequest( const absl::optional<std::pair<int, int>>& target_aspect_ratio, const absl::optional<int>& max_pixel_count, - const absl::optional<int>& max_fps) RTC_LOCKS_EXCLUDED(critical_section_); + const absl::optional<int>& max_fps) RTC_LOCKS_EXCLUDED(mutex_); // Same as above, but allows setting two different target aspect ratios // depending on incoming frame orientation. This gives more fine-grained @@ -83,7 +82,7 @@ class VideoAdapter { const absl::optional<int>& max_landscape_pixel_count, const absl::optional<std::pair<int, int>>& target_portrait_aspect_ratio, const absl::optional<int>& max_portrait_pixel_count, - const absl::optional<int>& max_fps) RTC_LOCKS_EXCLUDED(critical_section_); + const absl::optional<int>& max_fps) RTC_LOCKS_EXCLUDED(mutex_); // Requests the output frame size from |AdaptFrameResolution| to have as close // as possible to |sink_wants.target_pixel_count| pixels (if set) @@ -96,24 +95,20 @@ class VideoAdapter { // |sink_wants.resolution_alignment|. // Note: Should be called from the sink only. void OnSinkWants(const rtc::VideoSinkWants& sink_wants) - RTC_LOCKS_EXCLUDED(critical_section_); + RTC_LOCKS_EXCLUDED(mutex_); private: // Determine if frame should be dropped based on input fps and requested fps. - bool KeepFrame(int64_t in_timestamp_ns) - RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_); - - int frames_in_ RTC_GUARDED_BY(critical_section_); // Number of input frames. - int frames_out_ - RTC_GUARDED_BY(critical_section_); // Number of output frames. - int frames_scaled_ - RTC_GUARDED_BY(critical_section_); // Number of frames scaled. + bool KeepFrame(int64_t in_timestamp_ns) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + + int frames_in_ RTC_GUARDED_BY(mutex_); // Number of input frames. + int frames_out_ RTC_GUARDED_BY(mutex_); // Number of output frames. + int frames_scaled_ RTC_GUARDED_BY(mutex_); // Number of frames scaled. int adaption_changes_ - RTC_GUARDED_BY(critical_section_); // Number of changes in scale factor. - int previous_width_ - RTC_GUARDED_BY(critical_section_); // Previous adapter output width. + RTC_GUARDED_BY(mutex_); // Number of changes in scale factor. + int previous_width_ RTC_GUARDED_BY(mutex_); // Previous adapter output width. int previous_height_ - RTC_GUARDED_BY(critical_section_); // Previous adapter output height. + RTC_GUARDED_BY(mutex_); // Previous adapter output height. const bool variable_start_scale_factor_; // The fixed source resolution alignment requirement. @@ -121,30 +116,27 @@ class VideoAdapter { // The currently applied resolution alignment, as given by the requirements: // - the fixed |source_resolution_alignment_|; and // - the latest |sink_wants.resolution_alignment|. - int resolution_alignment_ RTC_GUARDED_BY(critical_section_); + int resolution_alignment_ RTC_GUARDED_BY(mutex_); // The target timestamp for the next frame based on requested format. - absl::optional<int64_t> next_frame_timestamp_ns_ - RTC_GUARDED_BY(critical_section_); + absl::optional<int64_t> next_frame_timestamp_ns_ RTC_GUARDED_BY(mutex_); // Max number of pixels/fps requested via calls to OnOutputFormatRequest, // OnResolutionFramerateRequest respectively. // The adapted output format is the minimum of these. absl::optional<std::pair<int, int>> target_landscape_aspect_ratio_ - RTC_GUARDED_BY(critical_section_); - absl::optional<int> max_landscape_pixel_count_ - RTC_GUARDED_BY(critical_section_); + RTC_GUARDED_BY(mutex_); + absl::optional<int> max_landscape_pixel_count_ RTC_GUARDED_BY(mutex_); absl::optional<std::pair<int, int>> target_portrait_aspect_ratio_ - RTC_GUARDED_BY(critical_section_); - absl::optional<int> max_portrait_pixel_count_ - RTC_GUARDED_BY(critical_section_); - absl::optional<int> max_fps_ RTC_GUARDED_BY(critical_section_); - int resolution_request_target_pixel_count_ RTC_GUARDED_BY(critical_section_); - int resolution_request_max_pixel_count_ RTC_GUARDED_BY(critical_section_); - int max_framerate_request_ RTC_GUARDED_BY(critical_section_); + RTC_GUARDED_BY(mutex_); + absl::optional<int> max_portrait_pixel_count_ RTC_GUARDED_BY(mutex_); + absl::optional<int> max_fps_ RTC_GUARDED_BY(mutex_); + int resolution_request_target_pixel_count_ RTC_GUARDED_BY(mutex_); + int resolution_request_max_pixel_count_ RTC_GUARDED_BY(mutex_); + int max_framerate_request_ RTC_GUARDED_BY(mutex_); // The critical section to protect the above variables. - rtc::CriticalSection critical_section_; + webrtc::Mutex mutex_; RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter); }; |