mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-28 16:55:36 +00:00
The WGC capture session uses Direct3D11CaptureFramePool::CreateFreeThreaded, which dispatches FrameArrived callbacks on thread pool threads concurrently. MFEncoder::writeFrame() accesses non-thread-safe resources (ID3D11DeviceContext, IMFSinkWriter, shared staging texture and NV12 buffer) without synchronization, causing MP4 container corruption when callbacks overlap at high frame rates. Add a mutex to serialize writeFrame() and finalize() calls, preventing concurrent access to the D3D context and Media Foundation sink writer. Fixes #96