Ignore:
Timestamp:
Dec 28, 2016 3:40:07 AM (3 years ago)
Author:
nanang
Message:

Re #1900: More merged from trunk (r5512 mistakenly contains merged changes in third-party dir only).

Location:
pjproject/branches/projects/uwp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/uwp

  • pjproject/branches/projects/uwp/pjmedia/src/pjmedia-videodev/ios_opengl_dev.m

    r5052 r5513  
    2020#include <pj/assert.h> 
    2121#include <pj/log.h> 
     22#include <pj/os.h> 
    2223 
    2324#if defined(PJMEDIA_HAS_VIDEO) && PJMEDIA_HAS_VIDEO != 0 && \ 
     
    129130} 
    130131 
     132static 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 
    131141@implementation GLView 
    132142 
     
    267277     
    268278    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    }); 
    270282    if (!strm->gl_view) 
    271283        return PJ_ENOMEM; 
     
    405417        UIView *view = (UIView *)pval; 
    406418        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];}); 
    409420        return PJ_SUCCESS; 
    410421    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE) { 
    411422        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(^{ 
    413424            strm->gl_view.bounds = CGRectMake(0, 0, strm->param.disp_size.w, 
    414425                                              strm->param.disp_size.h); 
     
    417428    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION) { 
    418429        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(^{ 
    420431            strm->gl_view.center = CGPointMake(strm->param.window_pos.x + 
    421432                                               strm->param.disp_size.w/2.0, 
     
    425436        return PJ_SUCCESS; 
    426437    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE) { 
    427         dispatch_async(dispatch_get_main_queue(), ^{ 
     438        dispatch_sync_on_main_queue(^{ 
    428439            strm->gl_view.hidden = (BOOL)(*((pj_bool_t *)pval)); 
    429440        }); 
     
    433444        if (strm->param.orient == PJMEDIA_ORIENT_UNKNOWN) 
    434445            return PJ_SUCCESS; 
    435         dispatch_async(dispatch_get_main_queue(), ^{ 
     446        dispatch_sync_on_main_queue(^{ 
    436447            strm->gl_view.transform = 
    437448                CGAffineTransformMakeRotation(((int)strm->param.orient-1) * 
Note: See TracChangeset for help on using the changeset viewer.