From 212cb9e6013c8b11dd92105ac5d09e34a2be4ab7 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 21 Nov 2014 11:55:07 +0100 Subject: [PATCH] Fixed previews creation in the queue. --- Classes/SBQueue.m | 2 +- Classes/SBQueueController.m | 2 +- Classes/SBQueueItem.h | 4 ++-- Classes/SBQueueItem.m | 17 +++++++++++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Classes/SBQueue.m b/Classes/SBQueue.m index 59a216d..53c17ef 100644 --- a/Classes/SBQueue.m +++ b/Classes/SBQueue.m @@ -195,7 +195,7 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification"; self.currentItem.delegate = self; [self handleSBStatusWorking:0 index:self.currentIndex]; - noErr = [self.currentItem processItem:self.optimize error:&outError]; + noErr = [self.currentItem processWithOptions:self.optimize error:&outError]; // Check results if (self.cancelled) { diff --git a/Classes/SBQueueController.m b/Classes/SBQueueController.m index 135261f..360b752 100755 --- a/Classes/SBQueueController.m +++ b/Classes/SBQueueController.m @@ -210,7 +210,7 @@ static void *SBQueueContex = &SBQueueContex; dispatch_async(dispatch_get_global_queue(0, 0), ^{ if (!item.mp4File) - [item prepareItem:NULL]; + [item prepare:NULL]; MP42File *mp4 = item.mp4File; dispatch_sync(dispatch_get_main_queue(), ^{ diff --git a/Classes/SBQueueItem.h b/Classes/SBQueueItem.h index 8d178a3..807f299 100755 --- a/Classes/SBQueueItem.h +++ b/Classes/SBQueueItem.h @@ -56,8 +56,8 @@ typedef enum SBQueueItemStatus : NSInteger { - (void)addAction:(id)action; - (void)removeAction:(id)action; -- (BOOL)prepareItem:(NSError **)outError; -- (BOOL)processItem:(BOOL)optimize error:(NSError **)outError; +- (BOOL)prepare:(NSError **)outError; +- (BOOL)processWithOptions:(BOOL)optimize error:(NSError **)outError; - (void)cancel; @end diff --git a/Classes/SBQueueItem.m b/Classes/SBQueueItem.m index f3e9059..c99d459 100755 --- a/Classes/SBQueueItem.m +++ b/Classes/SBQueueItem.m @@ -55,9 +55,18 @@ NSFileManager *fileManager = [NSFileManager defaultManager]; unsigned long long originalFileSize = [[[fileManager attributesOfItemAtPath:[_fileURL path] error:nil] valueForKey:NSFileSize] unsignedLongLongValue]; + + NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; + if (originalFileSize > ALMOST_4GiB) { - _attributes = [[NSDictionary alloc] initWithObjectsAndKeys:@YES, MP4264BitData, nil]; + [attributes setObject:@YES forKey:MP4264BitData]; } + + if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"chaptersPreviewTrack"] boolValue]) { + [attributes setObject:@YES forKey:MP42GenerateChaptersPreviewTrack]; + } + + _attributes = [attributes copy]; } return self; @@ -145,7 +154,7 @@ #pragma mark Item processing -- (BOOL)prepareItem:(NSError **)outError { +- (BOOL)prepare:(NSError **)outError { if (![[NSFileManager defaultManager] fileExistsAtPath:[self.URL path]]) { if (outError) { NSDictionary *errorDetail = @{ NSLocalizedDescriptionKey : @"File not found", @@ -230,7 +239,7 @@ return YES; } -- (BOOL)processItem:(BOOL)optimize error:(NSError **)outError { +- (BOOL)processWithOptions:(BOOL)optimize error:(NSError **)outError { BOOL noErr = YES; #ifdef SB_SANDBOX @@ -240,7 +249,7 @@ // The file has been added directly to the queue if (!self.mp4File && self.URL) { - noErr = [self prepareItem:outError]; + noErr = [self prepare:outError]; } if (!noErr) { goto bail; }