Fix thread safety issues in VideoStream
Several fixes for race conditions and resource management in VideoStream:
-
pendingFrames mutex: Add
pendingFramesMutexto protectpendingFrameswhich is accessed from both the frame submission thread (sendFrameinserts) and the FreeRDP callback thread (onFrameAcknowledgeremoves). -
Atomic requestedFrameRate: Make
requestedFrameRateatomic since it is read by the frame submission thread and written by the main thread viaupdateRequestedFrameRate(). -
Destructor cleanup: Call
close()in the destructor to ensure the frame submission thread is stopped and resources are cleaned up. -
close() ordering: Stop the frame submission thread BEFORE closing the GFX context to prevent use-after-free. Clear pending state and reset
gfxContextto prevent double-close. -
Frame submission guard: Don't dequeue frames until
CapsAdvertisehas completed and the GFX channel is ready. Without this, the initial I-frame (keyframe) could be dequeued and dropped before the channel is ready, causing a black screen until the next keyframe.
Tested with: Windows 11 mstsc → KDE Plasma 6.6.1 (Wayland)