From 868b6134858779a20b45978101f2be0c630b69b0 Mon Sep 17 00:00:00 2001 From: robmikh Date: Tue, 14 Jan 2025 20:48:52 -0800 Subject: [PATCH] Use CreateFreeThreaded instead of Create in SimpleCapture --- Win32CaptureSample/SimpleCapture.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Win32CaptureSample/SimpleCapture.cpp b/Win32CaptureSample/SimpleCapture.cpp index 51fb3b9..98618da 100644 --- a/Win32CaptureSample/SimpleCapture.cpp +++ b/Win32CaptureSample/SimpleCapture.cpp @@ -36,12 +36,12 @@ SimpleCapture::SimpleCapture( m_swapChain = util::CreateDXGISwapChain(m_d3dDevice, static_cast(m_item.Size().Width), static_cast(m_item.Size().Height), static_cast(m_pixelFormat), 2); - // Creating our frame pool with 'Create' instead of 'CreateFreeThreaded' - // means that the frame pool's FrameArrived event is called on the thread - // the frame pool was created on. This also means that the creating thread - // must have a DispatcherQueue. If you use this method, it's best not to do - // it on the UI thread. - m_framePool = winrt::Direct3D11CaptureFramePool::Create(m_device, m_pixelFormat, 2, m_item.Size()); + // We use 'CreateFreeThreaded' instead of 'Create' so that the FrameArrived + // event fires on a thread other than our UI thread. If you use the 'Create' + // method, it's best not to do it on the UI thread. Using the 'Create' method + // also means you must have a DispatcherQueue on that thread and you must be + // pumping messages. + m_framePool = winrt::Direct3D11CaptureFramePool::CreateFreeThreaded(m_device, m_pixelFormat, 2, m_item.Size()); m_session = m_framePool.CreateCaptureSession(m_item); m_lastSize = m_item.Size(); m_framePool.FrameArrived({ this, &SimpleCapture::OnFrameArrived });