summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'macosx')
-rw-r--r--macosx/HBAppDelegate.m36
-rw-r--r--macosx/HBAudio.m4
-rw-r--r--macosx/HBAudioDefaults.m4
-rw-r--r--macosx/HBAudioTrack.m11
-rw-r--r--macosx/HBController.m15
-rw-r--r--macosx/HBCore.h3
-rw-r--r--macosx/HBCore.m4
-rw-r--r--macosx/HBJob+HBJobConversion.m4
-rw-r--r--macosx/HBJob.m1
-rw-r--r--macosx/HBPreviewView.m21
-rw-r--r--macosx/HBQueue.m24
-rw-r--r--macosx/HBRemoteCore.h4
-rw-r--r--macosx/HBRemoteCore.m46
-rw-r--r--macosx/HBStateFormatter.m27
-rw-r--r--macosx/HBSubtitles.m2
-rw-r--r--macosx/HBSubtitlesDefaults.m1
-rw-r--r--macosx/HBSubtitlesTrack.m2
-rw-r--r--macosx/HBTitle.m1
-rw-r--r--macosx/HandBrakeXPCService/HBRemoteCoreProtocol.h4
-rw-r--r--macosx/HandBrakeXPCService/HandBrakeXPCService.m11
20 files changed, 159 insertions, 66 deletions
diff --git a/macosx/HBAppDelegate.m b/macosx/HBAppDelegate.m
index dbc52facb..a9b227f85 100644
--- a/macosx/HBAppDelegate.m
+++ b/macosx/HBAppDelegate.m
@@ -59,7 +59,7 @@
_outputPanel = [[HBOutputPanelController alloc] init];
// we init the HBPresetsManager
- NSURL *appSupportURL = [HBUtilities appSupportURL];
+ NSURL *appSupportURL = HBUtilities.appSupportURL;
_presetsManager = [[HBPresetsManager alloc] initWithURL:[appSupportURL URLByAppendingPathComponent:PRESET_FILE]];
// Queue
@@ -99,16 +99,18 @@
self.presetsMenuBuilder = [[HBPresetsMenuBuilder alloc] initWithMenu:self.presetsMenu
action:@selector(selectPresetFromMenu:)
- size:[NSFont systemFontSize]
+ size:NSFont.systemFontSize
presetsManager:self.presetsManager];
[self.presetsMenuBuilder build];
// Get the number of HandBrake instances currently running
- NSUInteger instances = [NSRunningApplication runningApplicationsWithBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]].count;
+ NSUInteger instances = [NSRunningApplication runningApplicationsWithBundleIdentifier:NSBundle.mainBundle.bundleIdentifier].count;
// Open debug output window now if it was visible when HB was closed
if ([ud boolForKey:@"OutputPanelIsOpen"])
+ {
[self showOutputPanel:nil];
+ }
// On Screen Notification
// We check to see if there is already another instance of hb running.
@@ -136,7 +138,9 @@
{
// Open queue window now if it was visible when HB was closed
if ([ud boolForKey:@"QueueWindowIsOpen"])
+ {
[self showQueueWindow:nil];
+ }
[self showMainWindow:self];
[self.mainController launchAction];
@@ -192,8 +196,8 @@
{
[self.presetsManager savePresets];
- [[NSUserDefaults standardUserDefaults] setBool:_queueController.window.isVisible forKey:@"QueueWindowIsOpen"];
- [[NSUserDefaults standardUserDefaults] setBool:_outputPanel.window.isVisible forKey:@"OutputPanelIsOpen"];
+ [NSUserDefaults.standardUserDefaults setBool:_queueController.window.isVisible forKey:@"QueueWindowIsOpen"];
+ [NSUserDefaults.standardUserDefaults setBool:_outputPanel.window.isVisible forKey:@"OutputPanelIsOpen"];
_mainController = nil;
_queueController = nil;
@@ -236,7 +240,7 @@
*/
- (void)cleanEncodeLogs
{
- NSURL *directoryUrl = [[HBUtilities appSupportURL] URLByAppendingPathComponent:@"EncodeLogs"];
+ NSURL *directoryUrl = [HBUtilities.appSupportURL URLByAppendingPathComponent:@"EncodeLogs"];
if (directoryUrl)
{
@@ -264,15 +268,15 @@
- (void)cleanPreviews
{
- NSURL *previewDirectory = [[HBUtilities appSupportURL] URLByAppendingPathComponent:@"Previews"];
+ NSURL *previewDirectory = [HBUtilities.appSupportURL URLByAppendingPathComponent:@"Previews"];
if (previewDirectory)
{
- NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:previewDirectory
- includingPropertiesForKeys:nil
- options:NSDirectoryEnumerationSkipsSubdirectoryDescendants |
- NSDirectoryEnumerationSkipsPackageDescendants
- error:NULL];
+ NSArray *contents = [NSFileManager.defaultManager contentsOfDirectoryAtURL:previewDirectory
+ includingPropertiesForKeys:nil
+ options:NSDirectoryEnumerationSkipsSubdirectoryDescendants |
+ NSDirectoryEnumerationSkipsPackageDescendants
+ error:NULL];
NSFileManager *manager = [[NSFileManager alloc] init];
for (NSURL *url in contents)
@@ -372,18 +376,16 @@
- (IBAction)openHomepage:(id)sender
{
- [[NSWorkspace sharedWorkspace] openURL:[NSURL
- URLWithString:@"https://handbrake.fr/"]];
+ [NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:@"https://handbrake.fr/"]];
}
- (IBAction)openForums:(id)sender
{
- [[NSWorkspace sharedWorkspace] openURL:[NSURL
- URLWithString:@"https://forum.handbrake.fr/"]];
+ [NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:@"https://forum.handbrake.fr/"]];
}
- (IBAction)openUserGuide:(id)sender
{
- [[NSWorkspace sharedWorkspace] openURL:HBUtilities.documentationURL];
+ [NSWorkspace.sharedWorkspace openURL:HBUtilities.documentationURL];
}
@end
diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m
index f6427b8db..adbee0e3e 100644
--- a/macosx/HBAudio.m
+++ b/macosx/HBAudio.m
@@ -43,7 +43,7 @@ NSString *HBAudioEncoderChangedNotification = @"HBAudioEncoderChangedNotificatio
_tracks = [[NSMutableArray alloc] init];
_defaults = [[HBAudioDefaults alloc] init];
- // Add the none and foreign track to the source array
+ // Add the none track to the source array
NSMutableArray<HBTitleAudioTrack *> *sourceTracks = [job.title.audioTracks mutableCopy];
HBTitleAudioTrack *none = [[HBTitleAudioTrack alloc] initWithDisplayName:HBKitLocalizedString(@"None", @"HBAudio -> none track name")];
[sourceTracks insertObject:none atIndex:0];
@@ -279,7 +279,9 @@ NSString *HBAudioEncoderChangedNotification = @"HBAudioEncoderChangedNotificatio
decodeInt(_container); if (_container != HB_MUX_MP4 && _container != HB_MUX_MKV && _container != HB_MUX_WEBM) { goto fail; }
decodeCollectionOfObjects(_sourceTracks, NSArray, HBTitleAudioTrack);
+ if (_sourceTracks == nil || _sourceTracks.count < 1) { goto fail; }
decodeCollectionOfObjects(_tracks, NSMutableArray, HBAudioTrack);
+ if (_tracks == nil) { goto fail; }
for (HBAudioTrack *track in _tracks)
{
diff --git a/macosx/HBAudioDefaults.m b/macosx/HBAudioDefaults.m
index 0dbef621b..b7ec8d20d 100644
--- a/macosx/HBAudioDefaults.m
+++ b/macosx/HBAudioDefaults.m
@@ -474,9 +474,11 @@
goto fail;
}
- decodeObjectOrFail(_trackSelectionLanguages, NSMutableArray);
+ decodeCollectionOfObjects(_trackSelectionLanguages, NSMutableArray, NSString);
+ if (_trackSelectionLanguages == nil) { goto fail; }
decodeCollectionOfObjects(_tracksArray, NSMutableArray, HBAudioTrackPreset);
+ if (_tracksArray == nil) { goto fail; }
decodeBool(_allowAACPassthru);
decodeBool(_allowAC3Passthru);
diff --git a/macosx/HBAudioTrack.m b/macosx/HBAudioTrack.m
index c3cc22c3e..178dad195 100644
--- a/macosx/HBAudioTrack.m
+++ b/macosx/HBAudioTrack.m
@@ -216,6 +216,15 @@
_drc = drc;
}
+- (void)setTitle:(NSString *)title
+{
+ if (title != _title)
+ {
+ [[self.undo prepareWithInvocationTarget:self] setTitle:_title];
+ }
+ _title = title;
+}
+
#pragma mark - Validation
- (int)sanatizeEncoderValue:(int)proposedEncoder
@@ -517,6 +526,8 @@
copy->_gain = _gain;
copy->_drc = _drc;
+
+ copy->_title = [_title copy];
}
return copy;
diff --git a/macosx/HBController.m b/macosx/HBController.m
index dab3d55db..3c75b1ec7 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -41,6 +41,7 @@
#import "HBPreferencesKeys.h"
static void *HBControllerScanCoreContext = &HBControllerScanCoreContext;
+static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
@interface HBController () <HBPresetsViewControllerDelegate, HBTitleSelectionDelegate, NSDraggingDestination, NSPopoverDelegate>
{
@@ -313,14 +314,20 @@ static void *HBControllerScanCoreContext = &HBControllerScanCoreContext;
[NSNotificationCenter.defaultCenter addObserverForName:HBQueueDidChangeStateNotification object:_queue queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note) {
[self updateQueueUI];
}];
+
[self updateQueueUI];
+ // Presets menu
self.presetsMenuBuilder = [[HBPresetsMenuBuilder alloc] initWithMenu:self.presetsPopup.menu
action:@selector(selectPresetFromMenu:)
size:[NSFont smallSystemFontSize]
presetsManager:presetManager];
[self.presetsMenuBuilder build];
+ // Log level
+ [NSUserDefaultsController.sharedUserDefaultsController addObserver:self forKeyPath:@"values.LoggingLevel"
+ options:0 context:HBControllerLogLevelContext];
+
self.bottomConstrain.constant = -WINDOW_HEIGHT_OFFSET_INIT;
[self.window recalculateKeyViewLoop];
@@ -379,6 +386,10 @@ static void *HBControllerScanCoreContext = &HBControllerScanCoreContext;
[self _touchBar_validateUserInterfaceItems];
}
}
+ else if (context == HBControllerLogLevelContext)
+ {
+ self.core.logLevel = [NSUserDefaults.standardUserDefaults integerForKey:HBLoggingLevel];
+ }
else
{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
@@ -658,7 +669,7 @@ static void *HBControllerScanCoreContext = &HBControllerScanCoreContext;
[self.core scanURL:mediaURL
titleIndex:index
- previews:hb_num_previews minDuration:min_title_duration_seconds
+ previews:hb_num_previews minDuration:min_title_duration_seconds keepPreviews:YES
progressHandler:^(HBState state, HBProgress progress, NSString *info)
{
self->fSrcDVD2Field.stringValue = info;
@@ -1044,6 +1055,7 @@ static void *HBControllerScanCoreContext = &HBControllerScanCoreContext;
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:NSLocalizedString(@"Warning!", @"Invalid destination alert -> message")];
[alert setInformativeText:NSLocalizedString(@"This is not a valid destination directory!", @"Invalid destination alert -> informative text")];
+ [alert setAlertStyle:NSAlertStyleCritical];
[alert beginSheetModalForWindow:self.window completionHandler:handler];
}
else if ([job.fileURL isEqual:job.completeOutputURL]||
@@ -1052,6 +1064,7 @@ static void *HBControllerScanCoreContext = &HBControllerScanCoreContext;
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:NSLocalizedString(@"A file already exists at the selected destination.", @"Destination same as source alert -> message")];
[alert setInformativeText:NSLocalizedString(@"The destination is the same as the source, you can not overwrite your source file!", @"Destination same as source alert -> informative text")];
+ [alert setAlertStyle:NSAlertStyleCritical];
[alert beginSheetModalForWindow:self.window completionHandler:handler];
}
else if ([[NSFileManager defaultManager] fileExistsAtPath:job.completeOutputURL.path])
diff --git a/macosx/HBCore.h b/macosx/HBCore.h
index 77e507f4e..3d1160161 100644
--- a/macosx/HBCore.h
+++ b/macosx/HBCore.h
@@ -155,10 +155,11 @@ typedef void (^HBCoreCompletionHandler)(HBCoreResult result);
* @param index the index of the desired title. Use 0 to scan every title.
* @param previewsNum the number of previews image to generate.
* @param seconds the minimum duration of the wanted titles in seconds.
+ * @param keepPreviews whether the previews images are kept on disk or discarded.
* @param progressHandler a block called periodically with the progress information.
* @param completionHandler a block called with the scan result.
*/
-- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds progressHandler:(HBCoreProgressHandler)progressHandler completionHandler:(HBCoreCompletionHandler)completionHandler;
+- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds keepPreviews:(BOOL)keepPreviews progressHandler:(HBCoreProgressHandler)progressHandler completionHandler:(HBCoreCompletionHandler)completionHandler;
/**
* Cancels the scan execution.
diff --git a/macosx/HBCore.m b/macosx/HBCore.m
index c720c5795..e7f988a95 100644
--- a/macosx/HBCore.m
+++ b/macosx/HBCore.m
@@ -244,7 +244,7 @@ typedef void (^HBCoreCleanupHandler)(void);
return YES;
}
-- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds progressHandler:(HBCoreProgressHandler)progressHandler completionHandler:(HBCoreCompletionHandler)completionHandler
+- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds keepPreviews:(BOOL)keepPreviews progressHandler:(HBCoreProgressHandler)progressHandler completionHandler:(HBCoreCompletionHandler)completionHandler
{
NSAssert(self.state == HBStateIdle, @"[HBCore scanURL:] called while another scan or encode already in progress");
NSAssert(url, @"[HBCore scanURL:] called with nil url.");
@@ -281,7 +281,7 @@ typedef void (^HBCoreCleanupHandler)(void);
hb_scan(_hb_handle, url.fileSystemRepresentation,
(int)index, (int)previewsNum,
- 1, min_title_duration_ticks);
+ keepPreviews, min_title_duration_ticks);
// Start the timer to handle libhb state changes
[self startUpdateTimerWithInterval:0.2];
diff --git a/macosx/HBJob+HBJobConversion.m b/macosx/HBJob+HBJobConversion.m
index a58e1333b..8a7eb6c0a 100644
--- a/macosx/HBJob+HBJobConversion.m
+++ b/macosx/HBJob+HBJobConversion.m
@@ -260,7 +260,7 @@
hb_subtitle_config_t sub_config;
int type = subTrack.type;
- sub_config.name = NULL;
+ sub_config.name = subTrack.title.UTF8String;
sub_config.offset = subTrack.offset;
// we need to strncpy file name and codeset
@@ -289,6 +289,7 @@
if (subt != NULL)
{
hb_subtitle_config_t sub_config = subt->config;
+ sub_config.name = subTrack.title.UTF8String;
if (!subTrack.burnedIn && hb_subtitle_can_pass(subt->source, job->mux))
{
@@ -374,6 +375,7 @@
audio->out.bitrate = audioTrack.bitRate;
audio->out.samplerate = sampleRateToUse;
audio->out.dither_method = hb_audio_dither_get_default();
+ audio->out.name = audioTrack.title.UTF8String;
// output is not passthru so apply gain
if (!(audioTrack.encoder & HB_ACODEC_PASS_FLAG))
diff --git a/macosx/HBJob.m b/macosx/HBJob.m
index ad32a0895..9bf41c49a 100644
--- a/macosx/HBJob.m
+++ b/macosx/HBJob.m
@@ -482,6 +482,7 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification";
decodeBool(_chaptersEnabled);
decodeCollectionOfObjects(_chapterTitles, NSArray, HBChapter);
+ if (_chapterTitles == nil) { goto fail; }
return self;
}
diff --git a/macosx/HBPreviewView.m b/macosx/HBPreviewView.m
index 518f82061..c9ec8bbd2 100644
--- a/macosx/HBPreviewView.m
+++ b/macosx/HBPreviewView.m
@@ -17,6 +17,7 @@
@property (nonatomic, readwrite) CGFloat scale;
@property (nonatomic, readwrite) NSRect pictureFrame;
+@property (nonatomic, readwrite) CGFloat scaleFactor;
@end
@@ -90,6 +91,14 @@
_pictureFrame = _pictureLayer.frame;
}
+- (void)viewDidChangeBackingProperties
+{
+ if (self.window)
+ {
+ self.scaleFactor = self.window.backingScaleFactor;
+ }
+}
+
- (void)setImage:(CGImageRef)image
{
_image = image;
@@ -167,10 +176,8 @@
if (imageSize.width > 0 && imageSize.height > 0) {
- if (self.window)
- {
- backingScaleFactor = self.window.backingScaleFactor;
- }
+ backingScaleFactor = self.scaleFactor;
+
// HiDPI mode usually display everything
// with double pixel count, but we don't
// want to double the size of the video
@@ -238,13 +245,13 @@
*/
- (NSSize)optimalViewSizeForImageSize:(NSSize)imageSize minSize:(NSSize)minSize
{
- if (self.window.backingScaleFactor != 1.0)
+ if (self.scaleFactor != 1.0)
{
// HiDPI mode usually display everything
// with double pixel count, but we don't
// want to double the size of the video
- imageSize.height /= self.window.backingScaleFactor;
- imageSize.width /= self.window.backingScaleFactor;
+ imageSize.height /= self.scaleFactor;
+ imageSize.width /= self.scaleFactor;
}
NSSize screenSize = self.window.screen.visibleFrame.size;
diff --git a/macosx/HBQueue.m b/macosx/HBQueue.m
index 9d2f32ba9..0d812b1d8 100644
--- a/macosx/HBQueue.m
+++ b/macosx/HBQueue.m
@@ -12,6 +12,7 @@
#import "HBJobOutputFileWriter.h"
static void *HBQueueContext = &HBQueueContext;
+static void *HBQueueLogLevelContext = &HBQueueLogLevelContext;
NSString * const HBQueueDidChangeStateNotification = @"HBQueueDidChangeStateNotification";
@@ -78,6 +79,8 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial
context:HBQueueContext];
+ [NSUserDefaultsController.sharedUserDefaultsController addObserver:self forKeyPath:@"values.LoggingLevel"
+ options:0 context:HBQueueLogLevelContext];
}
return self;
}
@@ -88,6 +91,10 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
{
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self];
}
+ else if (context == HBQueueLogLevelContext)
+ {
+ self.core.logLevel = [NSUserDefaults.standardUserDefaults integerForKey:HBLoggingLevel];
+ }
else
{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
@@ -431,7 +438,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (BOOL)canEncode
{
- return self.pendingItemsCount > 0;
+ return self.pendingItemsCount > 0 && ![self isEncoding];
}
- (BOOL)isEncoding
@@ -549,7 +556,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (void)start
{
- if (self.canEncode && self.core.state == HBStateIdle)
+ if (self.canEncode)
{
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidStartNotification object:self];
[self.core preventSleep];
@@ -720,6 +727,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
titleIndex:item.job.titleIdx
previews:10
minDuration:0
+ keepPreviews:NO
progressHandler:progressHandler
completionHandler:completionHandler];
}
@@ -802,8 +810,11 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
*/
- (void)cancelCurrentItemAndStop
{
- self.stop = YES;
- [self doCancelCurrentItem];
+ if (self.core.state != HBStateIdle)
+ {
+ self.stop = YES;
+ [self doCancelCurrentItem];
+ }
}
/**
@@ -811,7 +822,10 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
*/
- (void)finishCurrentAndStop
{
- self.stop = YES;
+ if (self.core.state != HBStateIdle)
+ {
+ self.stop = YES;
+ }
}
@end
diff --git a/macosx/HBRemoteCore.h b/macosx/HBRemoteCore.h
index 0193743f6..add53710e 100644
--- a/macosx/HBRemoteCore.h
+++ b/macosx/HBRemoteCore.h
@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithLogLevel:(NSInteger)level name:(NSString *)name;
- (void)invalidate;
+@property (nonatomic, readwrite) NSInteger logLevel;
+
@property (nonatomic, readonly) HBState state;
@property (nonatomic, readonly) HBRedirect *stdoutRedirect;
@@ -24,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)preventSleep;
- (void)allowSleep;
-- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds progressHandler:(HBCoreProgressHandler)progressHandler completionHandler:(HBCoreCompletionHandler)completionHandler;
+- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds keepPreviews:(BOOL)keepPreviews progressHandler:(nonnull HBCoreProgressHandler)progressHandler completionHandler:(nonnull HBCoreCompletionHandler)completionHandler;
- (void)cancelScan;
diff --git a/macosx/HBRemoteCore.m b/macosx/HBRemoteCore.m
index ff03a4ddd..abb1a375e 100644
--- a/macosx/HBRemoteCore.m
+++ b/macosx/HBRemoteCore.m
@@ -55,7 +55,18 @@
});
};
- _proxy = [_connection remoteObjectProxy];
+ _connection.invalidationHandler = ^{
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [weakSelf forwardError:@"XPC: Service connection was invalidated\n"];
+ });
+ };
+
+ _proxy = [_connection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [self forwardError:@"XPC: Service did report an error\n"];
+ [self forwardError:error.description];
+ });
+ }];
[_connection resume];
}
@@ -65,28 +76,27 @@
[[_connection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {}] tearDown];
[_connection invalidate];
_connection = nil;
+ _proxy = nil;
}
- (void)handleInterruption
{
+ [_proxy setDVDNav:[NSUserDefaults.standardUserDefaults boolForKey:HBUseDvdNav]];
[_proxy setUpWithLogLevel:self.level name:self.name];
- if (self.state != HBStateIdle)
- {
- [self forwardError:@"XPC Service did crash"];
-
- HBCoreCompletionHandler handler = self.completionHandler;
+ HBCoreCompletionHandler handler = self.completionHandler;
- self.progressHandler = nil;
- self.completionHandler = nil;
+ self.progressHandler = nil;
+ self.completionHandler = nil;
- self.state = HBStateIdle;
+ self.state = HBStateIdle;
- if (handler)
- {
- handler(HBCoreResultFailed);
- }
+ if (handler)
+ {
+ handler(HBCoreResultFailed);
}
+
+ [self forwardError:@"XPC: Service did crash\n"];
}
- (instancetype)initWithLogLevel:(NSInteger)level name:(NSString *)name
@@ -108,6 +118,12 @@
});
}
+- (void)setLogLevel:(NSInteger)logLevel
+{
+ _logLevel = logLevel;
+ [_proxy setLogLevel:logLevel];
+}
+
- (void)setAutomaticallyPreventSleep:(BOOL)automaticallyPreventSleep
{
[_proxy setAutomaticallyPreventSleep:automaticallyPreventSleep];
@@ -123,7 +139,7 @@
[_proxy preventSleep];
}
-- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds progressHandler:(nonnull HBCoreProgressHandler)progressHandler completionHandler:(nonnull HBCoreCompletionHandler)completionHandler
+- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds keepPreviews:(BOOL)keepPreviews progressHandler:(nonnull HBCoreProgressHandler)progressHandler completionHandler:(nonnull HBCoreCompletionHandler)completionHandler
{
#ifdef __SANDBOX_ENABLED__
@@ -143,7 +159,7 @@
__weak HBRemoteCore *weakSelf = self;
- [_proxy scanURL:url titleIndex:index previews:previewsNum minDuration:seconds withReply:^(HBCoreResult result) {
+ [_proxy scanURL:url titleIndex:index previews:previewsNum minDuration:seconds keepPreviews:keepPreviews withReply:^(HBCoreResult result) {
dispatch_sync(dispatch_get_main_queue(), ^{
HBCoreCompletionHandler handler = weakSelf.completionHandler;
weakSelf.completionHandler = nil;
diff --git a/macosx/HBStateFormatter.m b/macosx/HBStateFormatter.m
index 7993aaa32..876b10d41 100644
--- a/macosx/HBStateFormatter.m
+++ b/macosx/HBStateFormatter.m
@@ -55,21 +55,28 @@
}
}
- if (_showPassNumber && p.pass_count > -1)
+ if (_showPassNumber)
{
- if (p.pass_id == HB_PASS_SUBTITLE)
+ if (p.pass_count > -1)
{
- NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@"Pass %d %@ of %d, %.2f %%", @"HBStateFormatter -> work pass number format"),
- p.pass,
- HBKitLocalizedString(@"(subtitle scan)", @"HBStateFormatter -> work pass type format"),
- p.pass_count, 100.0 * p.progress];
- [string appendString:desc];
+ if (p.pass_id == HB_PASS_SUBTITLE)
+ {
+ NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@"Pass %d %@ of %d, %.2f %%", @"HBStateFormatter -> work pass number format"),
+ p.pass,
+ HBKitLocalizedString(@"(subtitle scan)", @"HBStateFormatter -> work pass type format"),
+ p.pass_count, 100.0 * p.progress];
+ [string appendString:desc];
+ }
+ else
+ {
+ NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@"Pass %d of %d, %.2f %%", @"HBStateFormatter -> work pass number format"),
+ p.pass, p.pass_count, 100.0 * p.progress];
+ [string appendString:desc];
+ }
}
else
{
- NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@"Pass %d of %d, %.2f %%", @"HBStateFormatter -> work pass number format"),
- p.pass, p.pass_count, 100.0 * p.progress];
- [string appendString:desc];
+ [string appendString:HBKitLocalizedString(@"Pass 1", @"HBStateFormatter -> work first pass number format")];
}
}
diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m
index 017fbea24..8545d37d5 100644
--- a/macosx/HBSubtitles.m
+++ b/macosx/HBSubtitles.m
@@ -462,7 +462,9 @@
decodeInt(_container); if (_container != HB_MUX_MP4 && _container != HB_MUX_MKV && _container != HB_MUX_WEBM) { goto fail; }
decodeCollectionOfObjects(_sourceTracks, NSArray, HBTitleSubtitlesTrack);
+ if (_sourceTracks == nil || _sourceTracks.count < 1) { goto fail; }
decodeCollectionOfObjects(_tracks, NSMutableArray, HBSubtitlesTrack);
+ if (_tracks == nil) { goto fail; }
for (HBSubtitlesTrack *track in _tracks)
{
diff --git a/macosx/HBSubtitlesDefaults.m b/macosx/HBSubtitlesDefaults.m
index bfbe824c0..dfd71d3de 100644
--- a/macosx/HBSubtitlesDefaults.m
+++ b/macosx/HBSubtitlesDefaults.m
@@ -231,6 +231,7 @@
goto fail;
}
decodeCollectionOfObjects(_trackSelectionLanguages, NSMutableArray, NSString);
+ if (_trackSelectionLanguages == nil) { goto fail; }
decodeBool(_addForeignAudioSearch);
decodeBool(_addForeignAudioSubtitle);
diff --git a/macosx/HBSubtitlesTrack.m b/macosx/HBSubtitlesTrack.m
index 27d1d0b1d..fa17d72a0 100644
--- a/macosx/HBSubtitlesTrack.m
+++ b/macosx/HBSubtitlesTrack.m
@@ -331,6 +331,8 @@ static NSArray *_languagesArray = nil;
copy->_isoLanguage = [_isoLanguage copy];
copy->_charCode = [_charCode copy];
copy->_offset = _offset;
+
+ copy->_title = [_title copy];
}
return copy;
diff --git a/macosx/HBTitle.m b/macosx/HBTitle.m
index 201214227..78bb097ae 100644
--- a/macosx/HBTitle.m
+++ b/macosx/HBTitle.m
@@ -73,7 +73,6 @@
_channelLayout = audio->in.channel_layout;
_isoLanguageCode = @(audio->lang.iso639_2);
-
}
return self;
}
diff --git a/macosx/HandBrakeXPCService/HBRemoteCoreProtocol.h b/macosx/HandBrakeXPCService/HBRemoteCoreProtocol.h
index 15843007a..97c8870ef 100644
--- a/macosx/HandBrakeXPCService/HBRemoteCoreProtocol.h
+++ b/macosx/HandBrakeXPCService/HBRemoteCoreProtocol.h
@@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setUpWithLogLevel:(NSInteger)level name:(NSString *)name;
- (void)tearDown;
+- (void)setLogLevel:(NSInteger)logLevel;
+
- (void)provideResourceAccessWithBookmarks:(NSArray<NSData *> *)bookmarks;
- (void)setAutomaticallyPreventSleep:(BOOL)automaticallyPreventSleep;
@@ -22,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)preventSleep;
- (void)allowSleep;
-- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds withReply:(void (^)(HBCoreResult))reply;
+- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds keepPreviews:(BOOL)keepPreviews withReply:(void (^)(HBCoreResult))reply;
- (void)cancelScan;
- (void)encodeJob:(HBJob *)job withReply:(void (^)(HBCoreResult))reply;
diff --git a/macosx/HandBrakeXPCService/HandBrakeXPCService.m b/macosx/HandBrakeXPCService/HandBrakeXPCService.m
index 960f5b98a..facf01268 100644
--- a/macosx/HandBrakeXPCService/HandBrakeXPCService.m
+++ b/macosx/HandBrakeXPCService/HandBrakeXPCService.m
@@ -82,6 +82,13 @@ static void *HandBrakeXPCServiceContext = &HandBrakeXPCServiceContext;
[NSProcessInfo.processInfo enableSuddenTermination];
}
+- (void)setLogLevel:(NSInteger)logLevel
+{
+ dispatch_sync(_queue, ^{
+ self.core.logLevel = logLevel;
+ });
+}
+
- (void)provideResourceAccessWithBookmarks:(NSArray<NSData *> *)bookmarks
{
dispatch_sync(_queue, ^{
@@ -131,7 +138,7 @@ static void *HandBrakeXPCServiceContext = &HandBrakeXPCServiceContext;
});
}
-- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds withReply:(void (^)(HBCoreResult))reply
+- (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds keepPreviews:(BOOL)keepPreviews withReply:(void (^)(HBCoreResult))reply
{
dispatch_sync(_queue, ^{
void (^progressHandler)(HBState state, HBProgress progress, NSString *info) = ^(HBState state, HBProgress progress, NSString *info)
@@ -141,7 +148,7 @@ static void *HandBrakeXPCServiceContext = &HandBrakeXPCServiceContext;
self->_progressHandler = progressHandler;
self.reply = reply;
- [self.core scanURL:url titleIndex:index previews:previewsNum minDuration:seconds
+ [self.core scanURL:url titleIndex:index previews:previewsNum minDuration:seconds keepPreviews:keepPreviews
progressHandler:self.progressHandler
completionHandler:self.completionHandler];
});