From dd10b73a0f052a84f2c95ddb7397e7be744ff1a8 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 27 Oct 2017 09:07:53 +0200 Subject: [PATCH] Fix multiple MP42SampleBufferFlagEndOfFile being sent on the same track. --- MP42/MP42FileImporter.m | 2 +- MP42/MP42Muxer.m | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MP42/MP42FileImporter.m b/MP42/MP42FileImporter.m index e207642..9be0b1b 100644 --- a/MP42/MP42FileImporter.m +++ b/MP42/MP42FileImporter.m @@ -255,7 +255,7 @@ static NSArray *_supportedFileFormats; MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; sample->flags |= MP42SampleBufferFlagEndOfFile; sample->trackId = track.sourceId; - [self enqueue:sample]; + [track enqueue:sample]; } } diff --git a/MP42/MP42Muxer.m b/MP42/MP42Muxer.m index 2761176..1737ea2 100644 --- a/MP42/MP42Muxer.m +++ b/MP42/MP42Muxer.m @@ -526,6 +526,7 @@ NSUInteger tracksCount = _activeTracks.count; NSMutableArray *tracks = [_activeTracks copy]; NSMutableArray *nextTracks = nil; + for (;;) { @autoreleasepool { @@ -545,7 +546,7 @@ if (sampleBuffer->flags & MP42SampleBufferFlagEndOfFile) { // Tracks done, remove it from the loop - NSMutableArray *nextTracks = [tracks mutableCopy]; + nextTracks = nextTracks != nil ? nextTracks : [tracks mutableCopy]; [nextTracks removeObject:track]; done += 1; }