diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc index 2f7fac9f02..8c74c2bf24 100644 --- a/modules/desktop_capture/win/wgc_capture_session.cc +++ b/modules/desktop_capture/win/wgc_capture_session.cc @@ -75,7 +75,8 @@ enum class GetFrameResult { kGetContentSizeFailed = 9, kResizeMappedTextureFailed = 10, kRecreateFramePoolFailed = 11, - kMaxValue = kRecreateFramePoolFailed + kFramePoolEmpty = 12, + kMaxValue = kFramePoolEmpty }; void RecordStartCaptureResult(StartCaptureResult error) { @@ -332,10 +333,15 @@ HRESULT WgcCaptureSession::ProcessFrame() { } if (!capture_frame) { - // Avoid logging errors until at least one valid frame has been captured. - if (queue_.current_frame()) { - RTC_DLOG(LS_WARNING) << "Frame pool was empty => kFrameDropped."; + if (!queue_.current_frame()) { + // The frame pool was empty and so is the external queue. + RTC_DLOG(LS_ERROR) << "Frame pool was empty => kFrameDropped."; RecordGetFrameResult(GetFrameResult::kFrameDropped); + } else { + // The frame pool was empty but there is still one old frame available in + // external the queue. + RTC_DLOG(LS_WARNING) << "Frame pool was empty => kFramePoolEmpty."; + RecordGetFrameResult(GetFrameResult::kFramePoolEmpty); } return E_FAIL; } diff --git a/modules/desktop_capture/win/wgc_capture_session.h b/modules/desktop_capture/win/wgc_capture_session.h index 8084bf1e37..d2901d9199 100644 --- a/modules/desktop_capture/win/wgc_capture_session.h +++ b/modules/desktop_capture/win/wgc_capture_session.h @@ -52,10 +52,12 @@ class WgcCaptureSession final { return is_capture_started_; } - // We only keep 1 buffer in the internal frame pool to reduce the latency as - // much as possible. + // We keep 2 buffers in the frame pool since it results in a good compromise + // between latency/capture-rate and the rate at which + // Direct3D11CaptureFramePool.TryGetNextFrame returns NULL and we have to fall + // back to providing a copy from our external queue instead. // We make this public for tests. - static constexpr int kNumBuffers = 1; + static constexpr int kNumBuffers = 2; private: // Initializes `mapped_texture_` with the properties of the `src_texture`,