From 56e830819f963ac35c17e1fbad89af6a07991882 Mon Sep 17 00:00:00 2001 From: henrika Date: Mon, 17 Apr 2023 12:40:35 +0200 Subject: [PATCH] Removes usage of FrameArrived event for WGC - part 2 Minor changes adding a final touch to https://webrtc-review.googlesource.com/c/src/+/301200 Bug: chromium:1428592 Change-Id: I6271b01f2c63645db080897f19fbdb343ae499b8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301520 Reviewed-by: Alexander Cooper Commit-Queue: Henrik Andreassson Cr-Commit-Position: refs/heads/main@{#39882} --- modules/desktop_capture/win/wgc_capture_session.cc | 7 ++----- modules/desktop_capture/win/wgc_capture_session.h | 3 --- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc index 5f3db106cc..64247d2739 100644 --- a/modules/desktop_capture/win/wgc_capture_session.cc +++ b/modules/desktop_capture/win/wgc_capture_session.cc @@ -234,7 +234,7 @@ void WgcCaptureSession::EnsureFrame() { RTC_DLOG(LS_WARNING) << "ProcessFrame failed during startup: " << hr; } } - RTC_LOG_IF(LS_ERROR, !is_frame_captured_) + RTC_LOG_IF(LS_ERROR, !queue_.current_frame()) << "Unable to process a valid frame even after trying 10 times."; } @@ -242,7 +242,6 @@ bool WgcCaptureSession::GetFrame(std::unique_ptr* output_frame) { RTC_DCHECK_RUN_ON(&sequence_checker_); EnsureFrame(); - RTC_DCHECK(is_frame_captured_); // Return a NULL frame and false as `result` if we still don't have a valid // frame. This will lead to a DesktopCapturer::Result::ERROR_PERMANENT being @@ -310,15 +309,13 @@ HRESULT WgcCaptureSession::ProcessFrame() { if (!capture_frame) { // Avoid logging errors until at least one valid frame has been captured. - if (is_frame_captured_) { + if (queue_.current_frame()) { RTC_DLOG(LS_WARNING) << "Frame pool was empty => kFrameDropped."; RecordGetFrameResult(GetFrameResult::kFrameDropped); } return E_FAIL; } - is_frame_captured_ = true; - queue_.MoveToNextFrame(); if (queue_.current_frame() && queue_.current_frame()->IsShared()) { RTC_DLOG(LS_VERBOSE) << "Overwriting frame that is still shared."; diff --git a/modules/desktop_capture/win/wgc_capture_session.h b/modules/desktop_capture/win/wgc_capture_session.h index c25ef0f105..ee15096eab 100644 --- a/modules/desktop_capture/win/wgc_capture_session.h +++ b/modules/desktop_capture/win/wgc_capture_session.h @@ -130,9 +130,6 @@ class WgcCaptureSession final { bool item_closed_ = false; bool is_capture_started_ = false; - // Set to true when at least one frame has been captured. - bool is_frame_captured_ = false; - // Caches the value of DesktopCaptureOptions.allow_wgc_zero_hertz() in // StartCapture(). Adds 0Hz detection in ProcessFrame() when enabled which // adds complexity since memcmp() is performed on two successive frames.