From b2af9fef1941b1c04b6ed0fa5e8d4cacb001a491 Mon Sep 17 00:00:00 2001 From: YuAo Date: Tue, 15 Feb 2022 16:15:50 +0800 Subject: [PATCH] [Recorder] audio buffer grouping logic fix --- Sources/VideoIO/MultitrackMovieRecorder.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/VideoIO/MultitrackMovieRecorder.swift b/Sources/VideoIO/MultitrackMovieRecorder.swift index 03b8f7e..35b372b 100644 --- a/Sources/VideoIO/MultitrackMovieRecorder.swift +++ b/Sources/VideoIO/MultitrackMovieRecorder.swift @@ -422,7 +422,7 @@ public final class MultitrackMovieRecorder { guard self.pendingAudioSampleBuffers.count > 0 else { return } - let (groupsToBeAppended, pendingGroups) = pendingAudioSampleBuffers.stableGroup(using: { $0.endTime >= lastVideoSampleTime }) + let (groupsToBeAppended, pendingGroups) = pendingAudioSampleBuffers.stableGroup(using: { $0.endTime <= lastVideoSampleTime }) for group in groupsToBeAppended { try self.appendAudioSampleBufferGroup(group) } @@ -431,7 +431,7 @@ public final class MultitrackMovieRecorder { private func tryAppendingAudioSampleBufferGroup(_ group: SampleBufferGroup) throws { dispatchPrecondition(condition: .onQueue(self.queue)) - if group.endTime >= self.lastVideoSampleTime { + if group.endTime > self.lastVideoSampleTime { self.pendingAudioSampleBuffers.append(group) } else { try self.appendAudioSampleBufferGroup(group)