Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/mac/APPRTCViewController.m

Issue 2920933002: Make sure UI methods get called on the main thread (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 CGSize _localVideoSize; 56 CGSize _localVideoSize;
57 CGSize _remoteVideoSize; 57 CGSize _remoteVideoSize;
58 } 58 }
59 59
60 @synthesize delegate = _delegate; 60 @synthesize delegate = _delegate;
61 @synthesize localVideoView = _localVideoView; 61 @synthesize localVideoView = _localVideoView;
62 @synthesize remoteVideoView = _remoteVideoView; 62 @synthesize remoteVideoView = _remoteVideoView;
63 63
64 64
65 - (void)displayLogMessage:(NSString *)message { 65 - (void)displayLogMessage:(NSString *)message {
66 _logView.string = 66 dispatch_async(dispatch_get_main_queue(), ^{
67 [NSString stringWithFormat:@"%@%@\n", _logView.string, message]; 67 _logView.string =
68 NSRange range = NSMakeRange(_logView.string.length, 0); 68 [NSString stringWithFormat:@"%@%@\n", _logView.string, message];
69 [_logView scrollRangeToVisible:range]; 69 NSRange range = NSMakeRange(_logView.string.length, 0);
70 [_logView scrollRangeToVisible:range];
71 });
70 } 72 }
71 73
72 #pragma mark - Private 74 #pragma mark - Private
73 75
74 - (instancetype)initWithFrame:(NSRect)frame { 76 - (instancetype)initWithFrame:(NSRect)frame {
75 if (self = [super initWithFrame:frame]) { 77 if (self = [super initWithFrame:frame]) {
76 [self setupViews]; 78 [self setupViews];
77 } 79 }
78 return self; 80 return self;
79 } 81 }
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 _client = client; 408 _client = client;
407 } 409 }
408 410
409 #pragma mark - Private 411 #pragma mark - Private
410 412
411 - (APPRTCMainView*)mainView { 413 - (APPRTCMainView*)mainView {
412 return (APPRTCMainView*)self.view; 414 return (APPRTCMainView*)self.view;
413 } 415 }
414 416
415 - (void)showAlertWithMessage:(NSString*)message { 417 - (void)showAlertWithMessage:(NSString*)message {
416 NSAlert* alert = [[NSAlert alloc] init]; 418 dispatch_async(dispatch_get_main_queue(), ^{
417 [alert setMessageText:message]; 419 NSAlert* alert = [[NSAlert alloc] init];
418 [alert runModal]; 420 [alert setMessageText:message];
421 [alert runModal];
422 });
419 } 423 }
420 424
421 - (void)resetUI { 425 - (void)resetUI {
422 [_remoteVideoTrack removeRenderer:self.mainView.remoteVideoView]; 426 [_remoteVideoTrack removeRenderer:self.mainView.remoteVideoView];
423 [_localVideoTrack removeRenderer:self.mainView.localVideoView]; 427 [_localVideoTrack removeRenderer:self.mainView.localVideoView];
424 _remoteVideoTrack = nil; 428 _remoteVideoTrack = nil;
425 _localVideoTrack = nil; 429 _localVideoTrack = nil;
426 [self.mainView.remoteVideoView renderFrame:nil]; 430 [self.mainView.remoteVideoView renderFrame:nil];
427 [self.mainView.localVideoView renderFrame:nil]; 431 [self.mainView.localVideoView renderFrame:nil];
428 } 432 }
429 433
430 - (void)disconnect { 434 - (void)disconnect {
431 [self resetUI]; 435 [self resetUI];
432 [_captureController stopCapture]; 436 [_captureController stopCapture];
433 _captureController = nil; 437 _captureController = nil;
434 [_client disconnect]; 438 [_client disconnect];
435 } 439 }
436 440
437 @end 441 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698