Commit 7788feea authored by Timur Pocheptsov's avatar Timur Pocheptsov
Browse files

AVFMediaAssetWriter - fix race conditions


Apple recommends starting/setting up a session (AVCaptureSession) on a
special queue and in the past we did this on the writer's queue.
Unfortunately, we also can access the same session from a different thread
and this results in race conditions and different weird crashes, for example,
we're calling start/stopRunning from the writer's queue, while the session
is being configured (in between beginConfiguration/commitConfiguration
on the recorder control's thread). So we have to limit access to the session
by the control's thread.

Apple docs say we have to ensure all appendSampleBuffer calls done
_before_ finishWriting. We ensure this by dispatching_sync an
empty block on the writer's queue after store-release of m_state.

We also do the same with video queue to ensure it does not try to
access viewfinder's data after stop/abort executed.

All these changes also make lock/mutex unneeded.

Task-number: QTBUG-54890
Change-Id: I38e86c879b6b62306bdfbeade65405d6ac3be9f3
Reviewed-by: default avatarYoann Lopes <yoann.lopes@qt.io>
parent ab940d8f
Branches
Tags
No related merge requests found
Showing with 67 additions and 65 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment