Leverage dispatch_queue_create_with_target when possible.

Replacing dispatch_queue_create followed by
dispatch_set_target_queue with dispatch_queue_create_with_target
is claimed to be source of GCD performance improvement:
https://developer.apple.com/videos/play/wwdc2017/706/
Video since 40 min. Slides since 199.

Bug: webrtc:9055
Change-Id: I0136f7faaef0951a7ad243bc8772f3ee952d5470
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168491
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Yura Yaroshevich <yura.yaroshevich@gmail.com>
Cr-Commit-Position: refs/heads/master@{#30781}
This commit is contained in:
Yura Yaroshevich
2020-03-12 13:18:01 +03:00
committed by Commit Bot
parent e6cedbbff6
commit de86381161
8 changed files with 75 additions and 11 deletions

View File

@ -21,6 +21,7 @@
#import "helpers/AVCaptureSession+DevicePosition.h"
#import "helpers/RTCDispatcher+Private.h"
#include "rtc_base/system/gcd_helpers.h"
const int64_t kNanosecondsPerSecond = 1000000000;
@ -415,10 +416,10 @@ const int64_t kNanosecondsPerSecond = 1000000000;
- (dispatch_queue_t)frameQueue {
if (!_frameQueue) {
_frameQueue =
dispatch_queue_create("org.webrtc.cameravideocapturer.video", DISPATCH_QUEUE_SERIAL);
dispatch_set_target_queue(_frameQueue,
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
_frameQueue = RTCDispatchQueueCreateWithTarget(
"org.webrtc.cameravideocapturer.video",
DISPATCH_QUEUE_SERIAL,
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
}
return _frameQueue;
}

View File

@ -13,6 +13,7 @@
#import "base/RTCLogging.h"
#import "base/RTCVideoFrameBuffer.h"
#import "components/video_frame_buffer/RTCCVPixelBuffer.h"
#include "rtc_base/system/gcd_helpers.h"
NSString *const kRTCFileVideoCapturerErrorDomain = @"org.webrtc.RTCFileVideoCapturer";
@ -118,9 +119,10 @@ typedef NS_ENUM(NSInteger, RTCFileVideoCapturerStatus) {
- (dispatch_queue_t)frameQueue {
if (!_frameQueue) {
_frameQueue = dispatch_queue_create("org.webrtc.filecapturer.video", DISPATCH_QUEUE_SERIAL);
dispatch_set_target_queue(_frameQueue,
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0));
_frameQueue = RTCDispatchQueueCreateWithTarget(
"org.webrtc.filecapturer.video",
DISPATCH_QUEUE_SERIAL,
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0));
}
return _frameQueue;
}