Skip to content

Commit

Permalink
Use CreateFreeThreaded instead of Create in SimpleCapture
Browse files Browse the repository at this point in the history
  • Loading branch information
robmikh committed Jan 15, 2025
1 parent 2a51573 commit 868b613
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Win32CaptureSample/SimpleCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ SimpleCapture::SimpleCapture(
m_swapChain = util::CreateDXGISwapChain(m_d3dDevice, static_cast<uint32_t>(m_item.Size().Width), static_cast<uint32_t>(m_item.Size().Height),
static_cast<DXGI_FORMAT>(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 });
Expand Down

0 comments on commit 868b613

Please sign in to comment.