Address followup feedback from webrtc-review 259457
https://webrtc-review.googlesource.com/c/src/+/259457 was a
cherry-pick to M102; as such changes were not made there to keep the
merge to just what had already landed. This addresses the issues raised
on that CL.
Bug: chromium:1316478
Change-Id: I94fad0aa6fe9c67aee5a2f2158524d75b51db48e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259660
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36631}
diff --git a/modules/desktop_capture/win/screen_capture_utils.cc b/modules/desktop_capture/win/screen_capture_utils.cc
index 2fc2c1a..3d4aecf 100644
--- a/modules/desktop_capture/win/screen_capture_utils.cc
+++ b/modules/desktop_capture/win/screen_capture_utils.cc
@@ -26,18 +26,14 @@
bool HasActiveDisplay() {
DesktopCapturer::SourceList screens;
- if (!GetScreenList(&screens))
- return false;
- return screens.size() >= 1;
+ return GetScreenList(&screens) && !screens.empty();
}
bool GetScreenList(DesktopCapturer::SourceList* screens,
std::vector<std::string>* device_names /* = nullptr */) {
- RTC_DCHECK_EQ(screens->size(), 0U);
- if (device_names) {
- RTC_DCHECK_EQ(device_names->size(), 0U);
- }
+ RTC_DCHECK(screens->empty());
+ RTC_DCHECK(!device_names || device_names->empty());
BOOL enum_result = TRUE;
for (int device_index = 0;; ++device_index) {
diff --git a/modules/desktop_capture/win/screen_capture_utils_unittest.cc b/modules/desktop_capture/win/screen_capture_utils_unittest.cc
index 0855554..2e58c6b1 100644
--- a/modules/desktop_capture/win/screen_capture_utils_unittest.cc
+++ b/modules/desktop_capture/win/screen_capture_utils_unittest.cc
@@ -34,7 +34,7 @@
TEST(ScreenCaptureUtilsTest, DeviceIndexToHmonitor) {
DesktopCapturer::SourceList screens;
ASSERT_TRUE(GetScreenList(&screens));
- if (screens.size() == 0) {
+ if (screens.empty()) {
RTC_LOG(LS_INFO)
<< "Skip ScreenCaptureUtilsTest on systems with no monitors.";
GTEST_SKIP();
diff --git a/modules/desktop_capture/win/wgc_capture_source.cc b/modules/desktop_capture/win/wgc_capture_source.cc
index c95847d..8b4ace4 100644
--- a/modules/desktop_capture/win/wgc_capture_source.cc
+++ b/modules/desktop_capture/win/wgc_capture_source.cc
@@ -166,7 +166,7 @@
// Ensure the monitor is still valid (hasn't disconnected) before trying to
// create the item. On versions of Windows before Win11, `CreateForMonitor`
// will crash if no displays are connected.
- if (!IsMonitorValid(*hmonitor_))
+ if (!IsMonitorValid(hmonitor_.value()))
return E_ABORT;
ComPtr<WGC::IGraphicsCaptureItem> item;