Changeset 40792ebd37f77c25079bcc0ae5ababc64703328b

Show
Ignore:
Timestamp:
08/06/07 11:24:23 (1 year ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1181294663 +0000
git-parent:

[ddb469c7f7f290d06411f690fa04b4b920882e76]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1181294663 +0000
Message:

Mac OS X gui: Comply to "Cocoa Thread Safety" guideline, that is, make creating, resizing, closing, the NSView on main thread.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/macosx/vout.m

    r2a2b478 r40792eb  
    758758- (void)enterFullscreen 
    759759{ 
    760     [[o_view class] resetVout: p_vout]; 
     760    [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES]; 
    761761    [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil]; 
    762762} 
     
    764764- (void)leaveFullscreen 
    765765{ 
    766     [[o_view class] resetVout: p_vout]; 
     766    [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES]; 
    767767    [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil]; 
    768768} 
  • modules/gui/macosx/voutgl.m

    r9ba00f5 r40792eb  
    172172        p_vout->p_sys->b_embedded = VLC_FALSE; 
    173173 
    174         p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; 
    175  
    176         /* Create the GL view */ 
    177         p_vout->p_sys->o_glview = [[VLCGLView alloc] initWithVout: p_vout]; 
    178         [p_vout->p_sys->o_glview autorelease]; 
    179  
    180         /* Spawn the window */ 
    181  
    182         if( !(p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout 
    183                         subView: p_vout->p_sys->o_glview frame: nil]) ) 
     174        [VLCGLView performSelectorOnMainThread:@selector(initVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES]; 
     175 
     176        /* Check to see if fillVoutWithNewView: was successfull */ 
     177 
     178        if( !p_vout->p_sys->o_vout_view ) 
    184179        { 
    185180            return VLC_EGENERIC; 
    186181        } 
     182 
    187183        p_vout->pf_init   = Init; 
    188184        p_vout->pf_end    = End; 
     
    210206 
    211207        /* Close the window */ 
    212         [p_vout->p_sys->o_vout_view closeVout]; 
     208        [p_vout->p_sys->o_vout_view performSelectorOnMainThread:@selector(closeVout) withObject:NULL waitUntilDone:YES]; 
    213209 
    214210        [o_pool release]; 
     
    308304 *****************************************************************************/ 
    309305@implementation VLCGLView 
     306+ (void)initVout:(NSValue *)arg 
     307{ 
     308    vout_thread_t * p_vout = [arg pointerValue]; 
     309 
     310    /* Create the GL view */ 
     311    p_vout->p_sys->o_glview = [[VLCGLView alloc] initWithVout: p_vout]; 
     312    [p_vout->p_sys->o_glview autorelease]; 
     313 
     314    /* Spawn the window */ 
     315    p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout 
     316                        subView: p_vout->p_sys->o_glview frame: nil]; 
     317} 
    310318 
    311319/* This function will reset the o_vout_view. It's useful to go fullscreen. */ 
    312 + (void)resetVout: (vout_thread_t *)p_vout 
    313 
     320+ (void)resetVout:(NSData *)arg 
     321
     322    vout_thread_t * p_vout = [arg pointerValue]; 
     323 
    314324    if( p_vout->b_fullscreen ) 
    315325    { 
     
    345355- (id) initWithVout: (vout_thread_t *) vout 
    346356{ 
     357    /* Must be called from main thread: 
     358     * "The NSView class is generally thread-safe, with a few exceptions. You 
     359     * should create, destroy, resize, move, and perform other operations on NSView 
     360     * objects only from the main thread of an application. Drawing from secondary 
     361     * threads is thread-safe as long as you bracket drawing calls with calls to 
     362     * lockFocusIfCanDraw and unlockFocus." Cocoa Thread Safety */ 
     363 
    347364    p_vout = vout; 
    348365 
     
    419436                ( bounds.size.height - y ) / 2, x, y ); 
    420437 
     438    [super reshape]; 
     439 
    421440    if( p_vout->p_sys->b_got_frame ) 
    422441    { 
     
    435454        Unlock( p_vout ); 
    436455    } 
    437     [super reshape]; 
    438456} 
    439457