A clean way of checking an assetWriterInput for readiness

The autor of Creating a Movie with an Image and Audio on iOS proposes the way of rechecking for assetwriter readiness.

// lines 52-55

 while !adaptor.assetWriterInput.isReadyForMoreMediaData { usleep(10) }
        adaptor.append(buffer, withPresentationTime: startFrameTime)


Is this the canonical way of querying AVFoundation's objects, or maybe there's a better way than sleep and try again loop? The only remotely related post I found is How to check if AvAssetWriter has finished writing the last frame, and has four years and no answer.

Answered by Dirk-FU in 737316022

What about requestMediaDataWhenReady( on queue: DispatchQueue, using block: @escaping () -> Void )(see documentation)

Accepted Answer

What about requestMediaDataWhenReady( on queue: DispatchQueue, using block: @escaping () -> Void )(see documentation)

A clean way of checking an assetWriterInput for readiness
 
 
Q