diff options
author | Damiano Galassi <[email protected]> | 2016-12-30 18:48:08 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2016-12-30 18:48:08 +0100 |
commit | f742b1590945a70f7a1998a3016671533094e81d (patch) | |
tree | 793c1f087affd4bfedb4523671f234af9e7b6a62 /macosx | |
parent | efe9d58da812f4f672f58c3db39ec3d624fda915 (diff) |
MacGui: make possible to configure on which queue HBCore will call the callback blocks.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HBCore.h | 4 | ||||
-rw-r--r-- | macosx/HBCore.m | 12 |
2 files changed, 7 insertions, 9 deletions
diff --git a/macosx/HBCore.h b/macosx/HBCore.h index 829bdb53b..e94b5ac12 100644 --- a/macosx/HBCore.h +++ b/macosx/HBCore.h @@ -82,8 +82,9 @@ typedef void (^HBCoreCompletionHandler)(HBCoreResult result); * functions HBCore are used. * * @param level the desired libhb logging level. + * @param queue the queue on which the callbacks will be called. */ -- (instancetype)initWithLogLevel:(int)level NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithLogLevel:(int)level queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; /** * Opens low level HandBrake library. This should be called once before other @@ -99,7 +100,6 @@ typedef void (^HBCoreCompletionHandler)(HBCoreResult result); */ @property (nonatomic, readwrite) int logLevel; - /** * State formatter. */ diff --git a/macosx/HBCore.m b/macosx/HBCore.m index a1847e727..5ab183b37 100644 --- a/macosx/HBCore.m +++ b/macosx/HBCore.m @@ -83,17 +83,17 @@ static void hb_error_handler(const char *errmsg) - (instancetype)init { - return [self initWithLogLevel:0]; + return [self initWithLogLevel:0 queue:dispatch_get_main_queue()]; } -- (instancetype)initWithLogLevel:(int)level +- (instancetype)initWithLogLevel:(int)level queue:(dispatch_queue_t)queue { self = [super init]; if (self) { _name = @"HBCore"; _state = HBStateIdle; - _updateTimerQueue = dispatch_queue_create("fr.handbrake.coreQueue", DISPATCH_QUEUE_SERIAL); + _updateTimerQueue = queue; _titles = @[]; _stateFormatter = [[HBStateFormatter alloc] init]; @@ -113,7 +113,7 @@ static void hb_error_handler(const char *errmsg) - (instancetype)initWithLogLevel:(int)level name:(NSString *)name { - self = [self initWithLogLevel:level]; + self = [self initWithLogLevel:level queue:dispatch_get_main_queue()]; if (self) { _name = [name copy]; @@ -128,8 +128,6 @@ static void hb_error_handler(const char *errmsg) { [self stopUpdateTimer]; - dispatch_release(_updateTimerQueue); - hb_close(&_hb_handle); _hb_handle = NULL; free(_hb_state); @@ -546,7 +544,7 @@ static void hb_error_handler(const char *errmsg) { if (!self.updateTimer) { - dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue()); + dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _updateTimerQueue); if (timer) { dispatch_source_set_timer(timer, dispatch_walltime(NULL, 0), (uint64_t)(seconds * NSEC_PER_SEC), (uint64_t)(seconds * NSEC_PER_SEC / 10)); |