fix: Fully synchronize buffers in RecordingSession
to account for late-running frames (#2206)
* fix: Fully synchronize `RecordingSession` to account for late Frames * Restructure Code * Update RecordingSession.swift * Fix last audio timestamp not being used * fix: Remove `capture/aborted` error * Update RecordingSession.swift * Don't log for every Frame * Format
This commit is contained in:
@@ -10,7 +10,10 @@ import AVFoundation
|
||||
import Foundation
|
||||
|
||||
extension AVCaptureSession {
|
||||
private var clock: CMClock {
|
||||
/**
|
||||
Returns the clock that is used by this AVCaptureSession.
|
||||
*/
|
||||
var clock: CMClock {
|
||||
if #available(iOS 15.4, *), let synchronizationClock {
|
||||
return synchronizationClock
|
||||
}
|
||||
@@ -24,7 +27,6 @@ extension AVCaptureSession {
|
||||
func synchronizeBuffer(_ buffer: CMSampleBuffer, toSession to: AVCaptureSession) {
|
||||
let timestamp = CMSampleBufferGetPresentationTimeStamp(buffer)
|
||||
let synchronizedTimestamp = CMSyncConvertTime(timestamp, from: clock, to: to.clock)
|
||||
ReactLogger.log(level: .info, message: "Synchronized Timestamp \(timestamp.seconds) -> \(synchronizedTimestamp.seconds)")
|
||||
CMSampleBufferSetOutputPresentationTimeStamp(buffer, newValue: synchronizedTimestamp)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user