From de4fd2f9ef7caee98bb49f4b1d5099906606c9e0 Mon Sep 17 00:00:00 2001 From: Austin Orion Date: Thu, 21 Jul 2022 10:21:02 -0700 Subject: [PATCH] WindowCapturerWinGdi shouldn't deliver SUCCESS and nullptr. Consumers expect the frame to be valid if Result::SUCCESS is delivered. If the frame is nullptr, we should deliver ERROR_TEMPORARY instead. Bug: webrtc:14265 Change-Id: If94a3ead38d7657d7b90bbe046256be697312216 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269223 Commit-Queue: Mark Foltz Reviewed-by: Mark Foltz Cr-Commit-Position: refs/heads/main@{#37590} --- .../win/window_capturer_win_gdi.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/desktop_capture/win/window_capturer_win_gdi.cc b/modules/desktop_capture/win/window_capturer_win_gdi.cc index 22b0c44aeb..6fd3a4db6e 100644 --- a/modules/desktop_capture/win/window_capturer_win_gdi.cc +++ b/modules/desktop_capture/win/window_capturer_win_gdi.cc @@ -160,17 +160,17 @@ void WindowCapturerWinGdi::CaptureFrame() { int64_t capture_start_time_nanos = rtc::TimeNanos(); CaptureResults results = CaptureFrame(/*capture_owned_windows*/ true); - - if (results.frame) { - int capture_time_ms = (rtc::TimeNanos() - capture_start_time_nanos) / - rtc::kNumNanosecsPerMillisec; - RTC_HISTOGRAM_COUNTS_1000( - "WebRTC.DesktopCapture.Win.WindowGdiCapturerFrameTime", - capture_time_ms); - results.frame->set_capture_time_ms(capture_time_ms); - results.frame->set_capturer_id(DesktopCapturerId::kWindowCapturerWinGdi); + if (!results.frame) { + callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr); + return; } + int capture_time_ms = (rtc::TimeNanos() - capture_start_time_nanos) / + rtc::kNumNanosecsPerMillisec; + RTC_HISTOGRAM_COUNTS_1000( + "WebRTC.DesktopCapture.Win.WindowGdiCapturerFrameTime", capture_time_ms); + results.frame->set_capture_time_ms(capture_time_ms); + results.frame->set_capturer_id(DesktopCapturerId::kWindowCapturerWinGdi); callback_->OnCaptureResult(results.result, std::move(results.frame)); }