I spent some time debugging a strange issue today where
outputMediaDataWillChange was not being consistently called in my
AVPlayerItemOutputPullDelegate implementation. Without this delegate function behaving properly it is impossible to suspend and resume the
CADisplayLink driving our display updates.
On looking at the initial configuration of the
AVPlayerItemOutput, I noticed a race condition:
With the above code it is completely possible (and happens with some frequency) for the
AVPlayer to attempt a call to its video outputs’
This works but it remains pretty strange as you wouldn’t expect the order of operations to matter before the output is added to an
AVPlayerItem. The world is a weird place.