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}
This commit is contained in:
Alexander Cooper 2022-04-20 14:30:15 -07:00 committed by WebRTC LUCI CQ
parent 58dfdd221a
commit f18841a843
3 changed files with 5 additions and 9 deletions

View File

@ -26,18 +26,14 @@ namespace webrtc {
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) {

View File

@ -34,7 +34,7 @@ TEST(ScreenCaptureUtilsTest, GetScreenList) {
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();

View File

@ -166,7 +166,7 @@ HRESULT WgcScreenSource::CreateCaptureItem(
// 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;