Init the FIFOs only when needed.

This commit is contained in:
Damiano Galassi committed 2017-10-01 16:35:39 +02:00
1 parent a668a5c949
commit 1f65513c84
6 files changed
+30 -27

No files matched your search

+8 -4
View File
@@ -512,12 +512,17 @@
NSUInteger tracksImportersCount = trackImportersArray.count;
NSUInteger tracksCount = _activeTracks.count;
NSMutableArray<MP42Track *> *tracks = [_activeTracks copy];
NSMutableArray<MP42Track *> *nextTracks = nil;
for (;;) {
@autoreleasepool {
usleep(1000);
if (nextTracks) {
tracks = nextTracks;
nextTracks = nil;
}
// Iterate the tracks array and mux the samples
for (MP42Track *track in tracks) {
MP42SampleBuffer *sampleBuffer = nil;
@@ -527,9 +532,8 @@
if (sampleBuffer->flags & MP42SampleBufferFlagEndOfFile) {
// Tracks done, remove it from the loop
NSMutableArray<MP42Track *> *copy = [tracks mutableCopy];
[copy removeObject:track];
tracks = copy;
NSMutableArray<MP42Track *> *nextTracks = [tracks mutableCopy];
[nextTracks removeObject:track];
done += 1;
}
else if (!MP4WriteSample(_fileHandle, trackId,