FFmpeg: Avoid finalizing encoders mid-init


If stop() was called while encoder threads were still initializing their
codecs, finalize() spawned the EncodingFinalizer thread with no
synchronization against handleEncoderInitialization(). The finalizer
could call stopAndDeleteThreads() and destroy the encoder threads while
handleEncoderInitialization() was still using them on the
RecordingEngine thread, or while an encoder was still inside init().

This patch adds tracking of resolution of each encoder (success or
failure) instead of only counting successful initializations.
handleEncoderInitialization() is replaced by handleEncoderResolved(bool
succeeded), which writes the header only if all encoders succeeded.

EncodingFinalizer now blocks on a semaphore until released after
encoders are initialized, so stopAndDeleteThreads() can never run while
an encoder might still be initializing.

Pick-to: 6.12
Change-Id: Ia2da13376874bb1af42dcb0f4f8dd5a556400d8c
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
commitb7c06b0677adff9aceeea1bc1a60c6392ea9bd94
parentadacaf87390cf3614cb59096f478c91e97464999
authorMikko Hallamaa <mikko.hallamaa@qt.io>
committerMikko Hallamaa <mikko.hallamaa@qt.io>
commit timeWed, 2 Sep 2026 07:55:21 +0000