Commit 05c53755 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Thumbnailer: don't alloc a thumbnailing libvlc instance on older device so we...

Thumbnailer: don't alloc a thumbnailing libvlc instance on older device so we don't trade in failing playback for slightly more beautiful thumbnails
parent 552cdc91
......@@ -27,6 +27,7 @@
#import "MLThumbnailerQueue.h"
#import "MLFile.h"
#import "MLCrashPreventer.h"
#import <sys/sysctl.h> // for sysctlbyname
@interface ThumbnailOperation : NSOperation <VLCMediaThumbnailerDelegate>
{
......@@ -141,7 +142,12 @@
{
self = [super init];
if (self != nil) {
_internalLibrary = [[VLCLibrary alloc] initWithOptions:@[@"--avcodec-threads=1", @"--avcodec-skip-frame=4", @"--avcodec-skip-idct=4", @"--deinterlace=-1", @"--avcodec-skiploopfilter=3"]];
int speedCategory = [self _deviceSpeedCategory];
APLog(@"running on a category %i device", speedCategory);
if (speedCategory < 2)
_internalLibrary = [VLCLibrary sharedLibrary];
else
_internalLibrary = [[VLCLibrary alloc] initWithOptions:@[@"--avcodec-threads=1", @"--avcodec-skip-frame=4", @"--avcodec-skip-idct=4", @"--deinterlace=-1", @"--avcodec-skiploopfilter=3"]];
_fileDescriptionToOperation = [[NSMutableDictionary alloc] init];
_queue = [[NSOperationQueue alloc] init];
[_queue setMaxConcurrentOperationCount:1];
......@@ -207,4 +213,27 @@ static inline NSString *hashFromFile(MLFile *file)
ThumbnailOperation *op = _fileDescriptionToOperation[hashFromFile(file)];
[op setQueuePriority:NSOperationQueuePriorityNormal];
}
- (int)_deviceSpeedCategory
{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *answer = malloc(size);
sysctlbyname("hw.machine", answer, &size, NULL, 0);
NSString *currentMachine = @(answer);
free(answer);
if ([currentMachine hasPrefix:@"iPhone2"] || [currentMachine hasPrefix:@"iPhone3"] || [currentMachine hasPrefix:@"iPad1"] || [currentMachine hasPrefix:@"iPod3"] || [currentMachine hasPrefix:@"iPod4"] || [currentMachine hasPrefix:@"iPad2"] || [currentMachine hasPrefix:@"iPhone4"] || [currentMachine hasPrefix:@"iPod4"]) {
// iPhone 3GS, iPhone 4, first gen. iPad, 3rd and 4th generation iPod touch, iPad 2, iPad mini (1st gen)
return 1;
} else if ([currentMachine hasPrefix:@"iPad3,1"] || [currentMachine hasPrefix:@"iPad3,2"] || [currentMachine hasPrefix:@"iPad3,3"] || [currentMachine hasPrefix:@"iPod5"]) {
// iPod 5, iPad 3
return 2;
} else {
// iPhone 5 + 5S, iPad 4, iPad Air, iPad mini with Retina Display
return 3;
}
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment