]> granicus.if.org Git - handbrake/commitdiff
MacGui: make possible to configure on which queue HBCore will call the callback blocks.
authorDamiano Galassi <damiog@gmail.com>
Fri, 30 Dec 2016 17:48:08 +0000 (18:48 +0100)
committerDamiano Galassi <damiog@gmail.com>
Mon, 9 Jan 2017 07:49:37 +0000 (08:49 +0100)
(cherry picked from commit f742b1590945a70f7a1998a3016671533094e81d)

macosx/HBCore.h
macosx/HBCore.m

index 829bdb53bfa0e2ce035d2fd950d2235e465fdddb..e94b5ac127d52851f6dd3d358efaeb2483bf39fd 100644 (file)
@@ -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.
  */
index ea4ebeddf1b29812c0fa251383948c011ed7a9f7..31f293448d6f0736b254a2c3fa319f61c783e233 100644 (file)
@@ -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);
@@ -547,7 +545,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));