- Timestamp:
- Aug 3, 2016 10:22:29 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-videodev/ios_opengl_dev.m
r5052 r5406 20 20 #include <pj/assert.h> 21 21 #include <pj/log.h> 22 #include <pj/os.h> 22 23 23 24 #if defined(PJMEDIA_HAS_VIDEO) && PJMEDIA_HAS_VIDEO != 0 && \ … … 129 130 } 130 131 132 static void dispatch_sync_on_main_queue(void (^block)(void)) 133 { 134 if ([NSThread isMainThread]) { 135 block(); 136 } else { 137 dispatch_sync(dispatch_get_main_queue(), block); 138 } 139 } 140 131 141 @implementation GLView 132 142 … … 267 277 268 278 rect = CGRectMake(0, 0, strm->param.disp_size.w, strm->param.disp_size.h); 269 strm->gl_view = [[GLView alloc] initWithFrame:rect]; 279 dispatch_sync_on_main_queue(^{ 280 strm->gl_view = [[GLView alloc] initWithFrame:rect]; 281 }); 270 282 if (!strm->gl_view) 271 283 return PJ_ENOMEM; … … 405 417 UIView *view = (UIView *)pval; 406 418 strm->param.window.info.ios.window = (void *)pval; 407 dispatch_async(dispatch_get_main_queue(), 408 ^{[view addSubview:strm->gl_view];}); 419 dispatch_sync_on_main_queue(^{[view addSubview:strm->gl_view];}); 409 420 return PJ_SUCCESS; 410 421 } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE) { 411 422 pj_memcpy(&strm->param.disp_size, pval, sizeof(strm->param.disp_size)); 412 dispatch_ async(dispatch_get_main_queue(),^{423 dispatch_sync_on_main_queue(^{ 413 424 strm->gl_view.bounds = CGRectMake(0, 0, strm->param.disp_size.w, 414 425 strm->param.disp_size.h); … … 417 428 } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION) { 418 429 pj_memcpy(&strm->param.window_pos, pval, sizeof(strm->param.window_pos)); 419 dispatch_ async(dispatch_get_main_queue(),^{430 dispatch_sync_on_main_queue(^{ 420 431 strm->gl_view.center = CGPointMake(strm->param.window_pos.x + 421 432 strm->param.disp_size.w/2.0, … … 425 436 return PJ_SUCCESS; 426 437 } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE) { 427 dispatch_ async(dispatch_get_main_queue(),^{438 dispatch_sync_on_main_queue(^{ 428 439 strm->gl_view.hidden = (BOOL)(*((pj_bool_t *)pval)); 429 440 }); … … 433 444 if (strm->param.orient == PJMEDIA_ORIENT_UNKNOWN) 434 445 return PJ_SUCCESS; 435 dispatch_ async(dispatch_get_main_queue(),^{446 dispatch_sync_on_main_queue(^{ 436 447 strm->gl_view.transform = 437 448 CGAffineTransformMakeRotation(((int)strm->param.orient-1) *
Note: See TracChangeset
for help on using the changeset viewer.