OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #import "RTCDispatcher.h" | |
12 | |
13 #import "RTCDispatcher+Private.h" | |
14 | |
15 static dispatch_queue_t kAudioSessionQueue = nil; | |
16 static dispatch_queue_t kCaptureSessionQueue = nil; | |
17 | |
18 @implementation RTCDispatcher | |
19 | |
20 + (void)initialize { | |
21 static dispatch_once_t onceToken; | |
22 dispatch_once(&onceToken, ^{ | |
23 kAudioSessionQueue = dispatch_queue_create( | |
24 "org.webrtc.RTCDispatcherAudioSession", | |
25 DISPATCH_QUEUE_SERIAL); | |
26 kCaptureSessionQueue = dispatch_queue_create( | |
27 "org.webrtc.RTCDispatcherCaptureSession", | |
28 DISPATCH_QUEUE_SERIAL); | |
29 }); | |
30 } | |
31 | |
32 + (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType | |
33 block:(dispatch_block_t)block { | |
34 dispatch_queue_t queue = [self dispatchQueueForType:dispatchType]; | |
35 dispatch_async(queue, block); | |
36 } | |
37 | |
38 #pragma mark - Private | |
39 | |
40 + (dispatch_queue_t)dispatchQueueForType:(RTCDispatcherQueueType)dispatchType { | |
41 switch (dispatchType) { | |
42 case RTCDispatcherTypeMain: | |
43 return dispatch_get_main_queue(); | |
44 case RTCDispatcherTypeCaptureSession: | |
45 return kCaptureSessionQueue; | |
46 case RTCDispatcherTypeAudioSession: | |
47 return kAudioSessionQueue; | |
48 } | |
49 } | |
50 | |
51 @end | |
52 | |
OLD | NEW |