NS_ASSUME_NONNULL_BEGIN
extern NSString * const HBQueueDidChangeStateNotification;
-extern NSString * const HBQueueNotificationStateKey; // HBState
extern NSString * const HBQueueDidAddItemNotification;
extern NSString * const HBQueueDidRemoveItemNotification;
static void *HBQueueContext = &HBQueueContext;
NSString * const HBQueueDidChangeStateNotification = @"HBQueueDidChangeStateNotification";
-NSString * const HBQueueNotificationStateKey = @"HBQueueNotificationStateKey";
NSString * const HBQueueDidAddItemNotification = @"HBQueueDidAddItemNotification";
NSString * const HBQueueDidRemoveItemNotification = @"HBQueueDidRemoveItemNotification";
{
if (context == HBQueueContext)
{
- [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self userInfo:@{HBQueueNotificationStateKey: @(self.core.state)}];
+ [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self];
}
else
{
- (BOOL)isEncoding
{
HBState s = self.core.state;
- return (s == HBStateScanning) || (s == HBStatePaused) || (s == HBStateWorking) || (s == HBStateMuxing) || (s == HBStateSearching);
+ return self.currentItem || (s == HBStateScanning) || (s == HBStatePaused) || (s == HBStateWorking) || (s == HBStateMuxing) || (s == HBStateSearching);
}
- (BOOL)canPause
self.failedItemsCount = failedCount;
self.completedItemsCount = completedCount;
- [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self userInfo:@{HBQueueNotificationStateKey: @(self.core.state)}];
+ [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self];
}
- (BOOL)isDiskSpaceLowAtURL:(NSURL *)url
[_connection resume];
}
-
- (void)invalidate
{
[[_connection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {}] tearDown];
{
if (self.state != HBStateIdle)
{
+ [self forwardError:@"XPC Service did crash"];
self.progressHandler = nil;
if (self.completionHandler)
{
[_proxy scanURL:url titleIndex:index previews:previewsNum minDuration:seconds withReply:^(HBCoreResult result) {
dispatch_sync(dispatch_get_main_queue(), ^{
+ HBCoreCompletionHandler handler = weakSelf.completionHandler;
+ weakSelf.completionHandler = nil;
weakSelf.progressHandler = nil;
- weakSelf.completionHandler(result);
+ handler(result);
});
}];
}
[_proxy encodeJob:job withReply:^(HBCoreResult result) {
dispatch_sync(dispatch_get_main_queue(), ^{
+ HBCoreCompletionHandler handler = weakSelf.completionHandler;
+ weakSelf.completionHandler = nil;
weakSelf.progressHandler = nil;
- weakSelf.completionHandler(result);
+ handler(result);
});
}];
}