Initialize a muxer instance only if there is some actual work to do.
This commit is contained in:
1 parent
4d3a9312ae
commit
6b73413c7c
1 file changed
+12
-3
+12
-3
@@ -695,7 +695,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
|
|||||||
[self removeMuxedTrack:track];
|
[self removeMuxedTrack:track];
|
||||||
|
|
||||||
// Init the muxer and prepare the work
|
// Init the muxer and prepare the work
|
||||||
self.muxer = [[[MP42Muxer alloc] initWithDelegate:self] autorelease];
|
NSMutableArray *tracksToMux = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
for (MP42Track *track in self.itracks) {
|
for (MP42Track *track in self.itracks) {
|
||||||
if (!track.muxed) {
|
if (!track.muxed) {
|
||||||
@@ -723,16 +723,23 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
|
|||||||
|
|
||||||
// Add the track to the muxer
|
// Add the track to the muxer
|
||||||
if (track.muxer_helper->importer)
|
if (track.muxer_helper->importer)
|
||||||
[self.muxer addTrack:track];
|
[tracksToMux addObject:track];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!noErr) {
|
if (!noErr) {
|
||||||
self.muxer = nil;
|
|
||||||
[self stopWriting];
|
[self stopWriting];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ([tracksToMux count]) {
|
||||||
|
self.muxer = [[[MP42Muxer alloc] initWithDelegate:self] autorelease];
|
||||||
|
|
||||||
|
for (MP42Track *track in tracksToMux) {
|
||||||
|
[self.muxer addTrack:track];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the muxer
|
||||||
noErr = [self.muxer setup:self.fileHandle error:outError];
|
noErr = [self.muxer setup:self.fileHandle error:outError];
|
||||||
|
|
||||||
if (!noErr) {
|
if (!noErr) {
|
||||||
@@ -744,7 +751,9 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
|
|||||||
// Start the muxer and wait
|
// Start the muxer and wait
|
||||||
[self.muxer work];
|
[self.muxer work];
|
||||||
self.muxer = nil;
|
self.muxer = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
[tracksToMux release];
|
||||||
[self.importers removeAllObjects];
|
[self.importers removeAllObjects];
|
||||||
|
|
||||||
// Update modified tracks properties
|
// Update modified tracks properties
|
||||||
|
|||||||
Reference in new issue
Block a user