diff --git a/Sources/Screen/Screen.swift b/Sources/Screen/Screen.swift index 2d736d8de..0e39a6f1b 100644 --- a/Sources/Screen/Screen.swift +++ b/Sources/Screen/Screen.swift @@ -180,10 +180,9 @@ extension Screen: ChoreographerDelegate { if let dictionary = CVBufferGetAttachments(pixelBuffer, .shouldNotPropagate) { CVBufferSetAttachments(pixelBuffer, dictionary, .shouldPropagate) } - let now = videoPresentationTimeStamp == .invalid ? - CMTime(seconds: timestamp, preferredTimescale: 1000000000) : - videoPresentationTimeStamp + let now = makePresentationTimeStamp(timestamp) guard currentPresentationTimeStamp < now else { + print("⚠️", currentPresentationTimeStamp, now) return } var timingInfo = CMSampleTimingInfo( @@ -206,4 +205,10 @@ extension Screen: ChoreographerDelegate { } currentPresentationTimeStamp = now } + + private func makePresentationTimeStamp(_ timestamp: TimeInterval) -> CMTime { + return videoPresentationTimeStamp == .invalid ? + CMTime(seconds: timestamp, preferredTimescale: 1000000000) : + videoPresentationTimeStamp + } }