diff --git a/AUTHORS b/AUTHORS index 6d700c9c80..e9f6f9b90c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -189,6 +189,7 @@ Hopin Ltd. <*@hopin.to> HyperConnect Inc. <*@hpcnt.com> Igalia S.L. <*@igalia.com> Intel Corporation <*@intel.com> +Island Technology, Inc. <*@island.io> LG Electronics, Inc. <*@lge.com> Life On Air Inc. <*@lifeonair.com> LiveKit <*@livekit.io> diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc index 3969654bce..7d02d41ce1 100644 --- a/modules/desktop_capture/win/wgc_capture_session.cc +++ b/modules/desktop_capture/win/wgc_capture_session.cc @@ -39,6 +39,7 @@ using Microsoft::WRL::ComPtr; namespace WGC = ABI::Windows::Graphics::Capture; +using IClosable = ABI::Windows::Foundation::IClosable; namespace webrtc { namespace { @@ -166,6 +167,18 @@ WgcCaptureSession::WgcCaptureSession(intptr_t source_id, WgcCaptureSession::~WgcCaptureSession() { RemoveEventHandlers(); + if (frame_pool_) { + ComPtr closable; + HRESULT hr = frame_pool_.As(&closable); + if (FAILED(hr)) { + RTC_LOG(LS_WARNING) << "Failed to query frame pool as IClosable: " << hr; + return; + } + hr = closable->Close(); + if (FAILED(hr)) { + RTC_LOG(LS_WARNING) << "Failed to close frame pool: " << hr; + } + } } HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) { @@ -748,7 +761,9 @@ HRESULT WgcCaptureSession::OnItemClosed(WGC::IGraphicsCaptureItem* sender, void WgcCaptureSession::RemoveEventHandlers() { RemoveItemClosedEventHandler(); - RemoveFrameArrivedEventHandler(); + if (frame_pool_) { + RemoveFrameArrivedEventHandler(); + } } void WgcCaptureSession::RemoveItemClosedEventHandler() {