Changeset e4ceccd32365e7199085f248fb09454d8e989054

Show
Ignore:
Timestamp:
27/07/04 18:20:32 (4 years ago)
Author:
Derk-Jan Hartman <hartman@videolan.org>
git-committer:
Derk-Jan Hartman <hartman@videolan.org> 1090945232 +0000
git-parent:

[359a9bafcc9026aa095325087867fc2954f8a8b9]

git-author:
Derk-Jan Hartman <hartman@videolan.org> 1090945232 +0000
Message:

-

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/darwin_specific.h

    r6de15a6 re4ceccd  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: darwin_specific.h,v 1.8 2004/01/25 18:17:08 zorglub Exp
     5 * $Id
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    2121 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. 
    2222 *****************************************************************************/ 
    23  
  • modules/gui/macosx/intf.m

    rbf680e8 re4ceccd  
    7070    p_intf->b_play = VLC_TRUE; 
    7171    p_intf->pf_run = Run; 
    72      
    73     [[VLCMain sharedInstance] setIntf: p_intf]; 
    7472 
    7573    return( 0 ); 
     
    8785    [p_intf->p_sys->o_sendport release]; 
    8886    [p_intf->p_sys->o_pool release]; 
    89  
     87     
    9088    free( p_intf->p_sys ); 
    9189} 
     
    10098     * (???) --Meuuh */ 
    10199    vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); 
     100    [[VLCMain sharedInstance] setIntf: p_intf]; 
    102101    [NSBundle loadNibNamed: @"MainMenu" owner: NSApp]; 
     102    [NSApp run]; 
     103    [[VLCMain sharedInstance] terminate]; 
    103104} 
    104105 
     
    107108    int i_ret = 0; 
    108109 
    109     NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; 
     110    //NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; 
    110111 
    111112    if( [target respondsToSelector: @selector(performSelectorOnMainThread: 
     
    114115        [target performSelectorOnMainThread: sel 
    115116                withObject: [NSValue valueWithPointer: p_arg] 
    116                 waitUntilDone: YES]; 
     117                waitUntilDone: NO]; 
    117118    } 
    118119    else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] )  
     
    162163    } 
    163164 
    164     [o_pool release]; 
     165    //[o_pool release]; 
    165166 
    166167    return( i_ret ); 
     
    291292{ 
    292293    unsigned int i_key = 0; 
    293     intf_thread_t * p_intf = VLCIntf; 
    294294    playlist_t *p_playlist; 
    295295    vlc_value_t val; 
     
    528528    vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); 
    529529} 
    530 /* 
     530 
    531531- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename 
    532532{ 
     
    537537    return( TRUE ); 
    538538} 
    539 */ 
     539 
    540540- (NSString *)localizedString:(char *)psz 
    541541{ 
     
    638638 
    639639    val.i_int = 0; 
    640     p_hotkeys = VLCIntf->p_vlc->p_hotkeys; 
     640    p_hotkeys = p_intf->p_vlc->p_hotkeys; 
    641641 
    642642    i_pressed_modifiers = [o_event modifierFlags]; 
     
    659659        if( p_hotkeys[i].i_key == val.i_int ) 
    660660        { 
    661             var_Set( VLCIntf->p_vlc, "key-pressed", val ); 
     661            var_Set( p_intf->p_vlc, "key-pressed", val ); 
    662662            return YES; 
    663663        } 
     
    697697{ 
    698698    NSDate * o_sleep_date; 
     699    /* new thread requires a new pool */ 
    699700    NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; 
    700701 
     
    810811                if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] ) 
    811812                { 
    812                     [o_vout_wnd updateTitle]; 
     813                    ;//[o_vout_wnd updateTitle]; 
    813814                } 
    814815            } 
     
    11351136- (IBAction)timesliderUpdate:(id)sender 
    11361137{ 
    1137     intf_thread_t * p_intf; 
    11381138    input_thread_t * p_input; 
    11391139    float f_updated; 
  • modules/gui/macosx/vout.h

    r1b031a9 re4ceccd  
    7676 
    7777/***************************************************************************** 
    78  * VLCVout interface 
    79  *****************************************************************************/ 
    80 @interface VLCVout : NSObject 
    81 { 
    82 } 
    83  
    84 - (void)createWindow:(NSValue *)o_value; 
    85 - (void)destroyWindow:(NSValue *)o_value; 
    86  
    87 @end 
    88  
    89 /***************************************************************************** 
    9078 * vout_sys_t: MacOS X video output method descriptor 
    9179 *****************************************************************************/ 
    9280struct vout_sys_t 
    9381{ 
    94     int i_opengl; 
    95      
     82    NSAutoreleasePool *o_pool; 
    9683    NSRect s_rect; 
    97     int b_pos_saved; 
    9884    VLCWindow * o_window; 
    9985 
     86    int i_opengl; 
     87    int b_pos_saved; 
     88     
    10089    vlc_bool_t b_mouse_moved; 
    10190    mtime_t i_time_mouse_last_moved; 
  • modules/gui/macosx/vout.m

    rbf680e8 re4ceccd  
    6969static void vout_Display   ( vout_thread_t *, picture_t * ); 
    7070 
    71 static int  CoSendRequest      ( vout_thread_t *, SEL ); 
    7271static int  CoCreateWindow     ( vout_thread_t * ); 
    7372static int  CoDestroyWindow    ( vout_thread_t * ); 
     
    120119    } 
    121120 
     121    p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; 
    122122    p_vout->p_sys->b_mouse_moved = VLC_TRUE; 
    123123    p_vout->p_sys->i_time_mouse_last_moved = mdate(); 
     
    160160            free( p_vout->p_sys ); 
    161161            return( 1 ); 
    162         }  
     162        } 
    163163 
    164164        /* Damn QT isn't thread safe. so keep a lock in the p_vlc object */ 
     
    169169         
    170170        vlc_mutex_unlock( &p_vout->p_vlc->quicktime_lock ); 
     171         
    171172        if( err == noErr && p_vout->p_sys->img_dc != 0 ) 
    172173        { 
     
    193194    } 
    194195 
    195     NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; 
    196196    NSArray * o_screens = [NSScreen screens]; 
    197197    if( [o_screens count] > 0 && var_Type( p_vout, "video-device" ) == 0 ) 
     
    237237        var_Set( p_vout, "intf-change", val ); 
    238238    } 
    239     [o_pool release]; 
    240239 
    241240    if( CoCreateWindow( p_vout ) ) 
     
    433432 *****************************************************************************/ 
    434433void E_(CloseVideo) ( vlc_object_t *p_this ) 
    435 {        
     434
     435    NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];  
    436436    vout_thread_t * p_vout = (vout_thread_t *)p_this;      
    437437 
     
    458458    } 
    459459 
     460    [o_pool release]; 
    460461    free( p_vout->p_sys ); 
    461462} 
     
    571572 
    572573/***************************************************************************** 
    573  * CoSendRequest: send request to interface thread 
    574  ***************************************************************************** 
    575  * Returns 0 on success, 1 otherwise 
    576  *****************************************************************************/ 
    577 static int CoSendRequest( vout_thread_t *p_vout, SEL sel ) 
    578 { 
    579     int i_ret = 0; 
    580     vlc_value_t val; 
    581     intf_thread_t * p_intf; 
    582  
    583     VLCVout * o_vlv = [[VLCVout alloc] init]; 
    584  
    585     if( ( i_ret = ExecuteOnMainThread( o_vlv, sel, (void *)p_vout ) ) ) 
    586     { 
    587         msg_Err( p_vout, "SendRequest: no way to communicate with mt" ); 
    588     } 
    589  
    590     [o_vlv release]; 
    591  
    592     /*This makes this function dependant of the presence of a macosx  
    593     interface. We do not check if this interface exists, since it has  
    594     already been done before.*/ 
    595  
    596     /*p_intf = VLCIntf; 
    597  
    598     val.b_bool = VLC_TRUE; 
    599     var_Create(p_intf,"intf-change",VLC_VAR_BOOL); 
    600     var_Set(p_intf, "intf-change",val); 
    601 */ 
    602     return( i_ret ); 
    603 } 
    604  
    605 /***************************************************************************** 
    606574 * CoCreateWindow: create new window  
    607575 ***************************************************************************** 
     
    610578static int CoCreateWindow( vout_thread_t *p_vout ) 
    611579{ 
    612     if( CoSendRequest( p_vout, @selector(createWindow:) ) ) 
    613     { 
    614         msg_Err( p_vout, "CoSendRequest (createWindow) failed" ); 
    615         return( 1 ); 
     580    vlc_value_t val; 
     581    VLCQTView * o_view; 
     582    NSScreen * o_screen; 
     583    vlc_bool_t b_main_screen; 
     584    NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; 
     585 
     586    p_vout->p_sys->o_window = [VLCWindow alloc]; 
     587    [p_vout->p_sys->o_window setReleasedWhenClosed: YES]; 
     588 
     589    if( var_Get( p_vout, "video-device", &val ) < 0 ) 
     590    { 
     591        o_screen = [NSScreen mainScreen]; 
     592        b_main_screen = 1; 
     593    } 
     594    else 
     595    { 
     596        NSArray *o_screens = [NSScreen screens]; 
     597        unsigned int i_index = val.i_int; 
     598         
     599        if( [o_screens count] < i_index ) 
     600        { 
     601            o_screen = [NSScreen mainScreen]; 
     602            b_main_screen = 1; 
     603        } 
     604        else 
     605        { 
     606            i_index--; 
     607            o_screen = [o_screens objectAtIndex: i_index]; 
     608            config_PutInt( p_vout, "macosx-vdev", i_index ); 
     609            b_main_screen = (i_index == 0); 
     610        } 
     611    }  
     612 
     613    if( p_vout->b_fullscreen ) 
     614    { 
     615        NSRect screen_rect = [o_screen frame]; 
     616        screen_rect.origin.x = screen_rect.origin.y = 0; 
     617 
     618        if ( b_main_screen && p_vout->p_sys->p_fullscreen_state == NULL ) 
     619            BeginFullScreen( &p_vout->p_sys->p_fullscreen_state, NULL, 0, 0, 
     620                             NULL, NULL, fullScreenAllowEvents ); 
     621 
     622        [p_vout->p_sys->o_window  
     623            initWithContentRect: screen_rect 
     624            styleMask: NSBorderlessWindowMask 
     625            backing: NSBackingStoreBuffered 
     626            defer: NO screen: o_screen]; 
     627 
     628        [p_vout->p_sys->o_window setVout: p_vout]; 
     629        p_vout->p_sys->b_mouse_moved = YES; 
     630        p_vout->p_sys->i_time_mouse_last_moved = mdate(); 
     631    } 
     632    else 
     633    { 
     634        unsigned int i_stylemask = NSTitledWindowMask | 
     635                                   NSMiniaturizableWindowMask | 
     636                                   NSClosableWindowMask | 
     637                                   NSResizableWindowMask; 
     638         
     639        if ( p_vout->p_sys->p_fullscreen_state != NULL ) 
     640            EndFullScreen ( p_vout->p_sys->p_fullscreen_state, NULL ); 
     641        p_vout->p_sys->p_fullscreen_state = NULL; 
     642 
     643        [p_vout->p_sys->o_window  
     644            initWithContentRect: p_vout->p_sys->s_rect 
     645            styleMask: i_stylemask 
     646            backing: NSBackingStoreBuffered 
     647            defer: NO screen: o_screen]; 
     648 
     649        [p_vout->p_sys->o_window setVout: p_vout]; 
     650        [p_vout->p_sys->o_window setAlphaValue: config_GetFloat( p_vout, "macosx-opaqueness" )]; 
     651         
     652        if( config_GetInt( p_vout, "video-on-top" ) ) 
     653        { 
     654            [p_vout->p_sys->o_window setLevel: NSStatusWindowLevel]; 
     655        } 
     656         
     657        if( !p_vout->p_sys->b_pos_saved )    
     658        { 
     659            [p_vout->p_sys->o_window center]; 
     660        } 
     661    } 
     662 
     663    if( !p_vout->p_sys->i_opengl ) 
     664    { 
     665        o_view = [[VLCQTView alloc] init]; 
     666        /* FIXME: [o_view setMenu:] */ 
     667        [p_vout->p_sys->o_window setContentView: o_view]; 
     668        [o_view autorelease]; 
     669 
     670        [o_view lockFocus]; 
     671        p_vout->p_sys->p_qdport = [o_view qdPort]; 
     672        [o_view unlockFocus]; 
     673    } 
     674    else 
     675    { 
     676#define o_glview p_vout->p_sys->o_glview 
     677        o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout]; 
     678        [p_vout->p_sys->o_window setContentView: o_glview]; 
     679        [o_glview autorelease]; 
     680#undef o_glview 
    616681    } 
    617682     
    618     return( 0 ); 
     683    [p_vout->p_sys->o_window updateTitle]; 
     684    [p_vout->p_sys->o_window makeKeyAndOrderFront: nil]; 
     685     
     686    [o_pool release]; 
     687    return( 0); 
    619688} 
    620689 
     
    626695static int CoDestroyWindow( vout_thread_t *p_vout ) 
    627696{ 
    628  
     697    NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; 
    629698    VLCHideMouse( p_vout, NO ); 
    630699 
    631     if( CoSendRequest( p_vout, @selector(destroyWindow:) ) ) 
    632     { 
    633         msg_Err( p_vout, "CoSendRequest (destroyWindow) failed" ); 
    634         return( 1 ); 
    635     } 
    636  
    637     return( 0 ); 
     700    if( !p_vout->b_fullscreen ) 
     701    { 
     702        NSRect s_rect; 
     703 
     704        s_rect = [[p_vout->p_sys->o_window contentView] frame]; 
     705        p_vout->p_sys->s_rect.size = s_rect.size; 
     706 
     707        s_rect = [p_vout->p_sys->o_window frame]; 
     708        p_vout->p_sys->s_rect.origin = s_rect.origin; 
     709 
     710        p_vout->p_sys->b_pos_saved = YES; 
     711    } 
     712     
     713    p_vout->p_sys->p_qdport = nil; 
     714    [p_vout->p_sys->o_window close]; 
     715    p_vout->p_sys->o_window = nil; 
     716    [o_pool release]; 
     717    return 0; 
    638718} 
    639719 
     
    645725static int CoToggleFullscreen( vout_thread_t *p_vout ) 
    646726{ 
     727    NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; 
     728 
    647729    if( !p_vout->p_sys->i_opengl ) 
    648730    { 
     
    685767    } 
    686768 
     769    [o_pool release]; 
    687770    return( 0 ); 
    688771} 
     
    10141097    return( YES ); 
    10151098} 
    1016  
     1099/* 
    10171100- (BOOL)performKeyEquivalent:(NSEvent *)o_event 
    10181101{ 
    10191102    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event]; 
    10201103} 
    1021  
     1104*/ 
    10221105- (void)keyDown:(NSEvent *)o_event 
    10231106{ 
     
    17391822 
    17401823@end 
    1741  
    1742 /***************************************************************************** 
    1743  * VLCVout implementation 
    1744  *****************************************************************************/ 
    1745 @implementation VLCVout 
    1746  
    1747 - (void)createWindow:(NSValue *)o_value 
    1748 { 
    1749     vlc_value_t val; 
    1750     VLCQTView * o_view; 
    1751     NSScreen * o_screen; 
    1752     vout_thread_t * p_vout; 
    1753     vlc_bool_t b_main_screen; 
    1754      
    1755     p_vout = (vout_thread_t *)[o_value pointerValue]; 
    1756  
    1757     p_vout->p_sys->o_window = [VLCWindow alloc]; 
    1758     [p_vout->p_sys->o_window setVout: p_vout]; 
    1759     [p_vout->p_sys->o_window setReleasedWhenClosed: YES]; 
    1760  
    1761     if( var_Get( p_vout, "video-device", &val ) < 0 ) 
    1762     { 
    1763         o_screen = [NSScreen mainScreen]; 
    1764         b_main_screen = 1; 
    1765     } 
    1766     else 
    1767     { 
    1768         NSArray *o_screens = [NSScreen screens]; 
    1769         unsigned int i_index = val.i_int; 
    1770          
    1771         if( [o_screens count] < i_index ) 
    1772         { 
    1773             o_screen = [NSScreen mainScreen]; 
    1774             b_main_screen = 1; 
    1775         } 
    1776         else 
    1777         { 
    1778             i_index--; 
    1779             o_screen = [o_screens objectAtIndex: i_index]; 
    1780             config_PutInt( p_vout, "macosx-vdev", i_index ); 
    1781             b_main_screen = (i_index == 0); 
    1782         } 
    1783     }  
    1784  
    1785     if( p_vout->b_fullscreen ) 
    1786     { 
    1787         NSRect screen_rect = [o_screen frame]; 
    1788         screen_rect.origin.x = screen_rect.origin.y = 0; 
    1789  
    1790         if ( b_main_screen && p_vout->p_sys->p_fullscreen_state == NULL ) 
    1791             BeginFullScreen( &p_vout->p_sys->p_fullscreen_state, NULL, 0, 0, 
    1792                              NULL, NULL, fullScreenAllowEvents ); 
    1793  
    1794         [p_vout->p_sys->o_window  
    1795             initWithContentRect: screen_rect 
    1796             styleMask: NSBorderlessWindowMask 
    1797             backing: NSBackingStoreBuffered 
    1798             defer: NO screen: o_screen]; 
    1799  
    1800         //[p_vout->p_sys->o_window setLevel: NSPopUpMenuWindowLevel - 1]; 
    1801         p_vout->p_sys->b_mouse_moved = YES; 
    1802         p_vout->p_sys->i_time_mouse_last_moved = mdate(); 
    1803     } 
    1804     else 
    1805     { 
    1806         unsigned int i_stylemask = NSTitledWindowMask | 
    1807                                    NSMiniaturizableWindowMask | 
    1808                                    NSClosableWindowMask | 
    1809                                    NSResizableWindowMask; 
    1810          
    1811         if ( p_vout->p_sys->p_fullscreen_state != NULL ) 
    1812             EndFullScreen ( p_vout->p_sys->p_fullscreen_state, NULL ); 
    1813         p_vout->p_sys->p_fullscreen_state = NULL; 
    1814  
    1815         [p_vout->p_sys->o_window  
    1816             initWithContentRect: p_vout->p_sys->s_rect 
    1817             styleMask: i_stylemask 
    1818             backing: NSBackingStoreBuffered 
    1819             defer: NO screen: o_screen]; 
    1820  
    1821         [p_vout->p_sys->o_window setAlphaValue: config_GetFloat( p_vout, "macosx-opaqueness" )]; 
    1822          
    1823         if( config_GetInt( p_vout, "video-on-top" ) ) 
    1824         { 
    1825             [p_vout->p_sys->o_window setLevel: NSStatusWindowLevel]; 
    1826         } 
    1827          
    1828         if( !p_vout->p_sys->b_pos_saved )    
    1829         { 
    1830             [p_vout->p_sys->o_window center]; 
    1831         } 
    1832     } 
    1833  
    1834     if( !p_vout->p_sys->i_opengl ) 
    1835     { 
    1836         o_view = [[VLCQTView alloc] init]; 
    1837         /* FIXME: [o_view setMenu:] */ 
    1838         [p_vout->p_sys->o_window setContentView: o_view]; 
    1839         [o_view autorelease]; 
    1840  
    1841         [o_view lockFocus]; 
    1842         p_vout->p_sys->p_qdport = [o_view qdPort]; 
    1843         [o_view unlockFocus]; 
    1844     } 
    1845     else 
    1846     { 
    1847 #define o_glview p_vout->p_sys->o_glview 
    1848         o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout]; 
    1849         [p_vout->p_sys->o_window setContentView: o_glview]; 
    1850         [o_glview autorelease]; 
    1851 #undef o_glview 
    1852     } 
    1853      
    1854     [p_vout->p_sys->o_window updateTitle]; 
    1855     [p_vout->p_sys->o_window makeKeyAndOrderFront: nil]; 
    1856  
    1857 } 
    1858  
    1859 - (void)destroyWindow:(NSValue *)o_value 
    1860 { 
    1861     vout_thread_t * p_vout; 
    1862  
    1863     p_vout = (vout_thread_t *)[o_value pointerValue]; 
    1864  
    1865     if( !p_vout->b_fullscreen ) 
    1866     { 
    1867         NSRect s_rect; 
    1868  
    1869         s_rect = [[p_vout->p_sys->o_window contentView] frame]; 
    1870         p_vout->p_sys->s_rect.size = s_rect.size; 
    1871  
    1872         s_rect = [p_vout->p_sys->o_window frame]; 
    1873         p_vout->p_sys->s_rect.origin = s_rect.origin; 
    1874  
    1875         p_vout->p_sys->b_pos_saved = YES; 
    1876     } 
    1877      
    1878     p_vout->p_sys->p_qdport = nil; 
    1879     [p_vout->p_sys->o_window close]; 
    1880     p_vout->p_sys->o_window = nil; 
    1881 } 
    1882  
    1883 @end 
  • src/interface/interface.c

    rbf680e8 re4ceccd  
    6161                            vlc_value_t , vlc_value_t , void * ); 
    6262 
     63#ifdef SYS_DARWIN 
     64/***************************************************************************** 
     65 * VLCApplication interface 
     66 *****************************************************************************/ 
     67@interface VLCApplication : NSApplication 
     68{ 
     69} 
     70 
     71@end 
     72#endif 
     73 
    6374/***************************************************************************** 
    6475 * intf_Create: prepare interface before main loop 
     
    132143{ 
    133144#ifdef SYS_DARWIN 
     145    NSAutoreleasePool * o_pool; 
     146 
    134147    if( p_intf->b_block ) 
    135148    { 
     
    144157    } 
    145158 
    146     if( p_intf->b_block && !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) ) 
    147     { 
    148     /* this is OSX, we are cheating :) 
    149            This is NOT I REPEAT NOT blocking since [NSApp run] is */ 
    150     p_intf->b_block = VLC_FALSE; 
    151  
    152         RunInterface( p_intf ); 
    153         p_intf->b_block = VLC_TRUE; 
    154     } 
    155     else if( p_intf->b_block && !strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) ) 
    156     { 
    157         /* VLC OS X in cli mode ( no blocking [NSApp run] ) 
    158            this is equal to running in normal non-OSX primary intf mode */ 
     159    if( p_intf->b_block && strncmp( p_intf->p_module->psz_shortname, "clivlc", 6) ) 
     160    { 
     161        o_pool = [[NSAutoreleasePool alloc] init]; 
     162    [VLCApplication sharedApplication]; 
     163    } 
     164 
     165    if( p_intf->b_block && ( !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) || 
     166                             !strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) ) ) 
     167    { 
     168        /* VLC in normal primary interface mode */ 
    159169        RunInterface( p_intf ); 
    160170        p_intf->b_die = VLC_TRUE; 
     
    162172    else 
    163173    { 
    164         /* If anything else is the primary intf and we are not in cli mode, 
    165            then don't make it blocking ([NSApp run] will be blocking)  
    166            but run it in a seperate thread. */ 
    167         p_intf->b_block = VLC_FALSE; 
     174        /* Run the interface in a separate thread */ 
     175        if( vlc_thread_create( p_intf, "interface", RunInterface, 
     176                               VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) 
     177        { 
     178            msg_Err( p_intf, "cannot spawn interface thread" ); 
     179            return VLC_EGENERIC; 
     180        } 
     181 
     182        if( p_intf->b_block ) 
     183        { 
     184            /* VLC in primary interface mode with a working macosx vout */ 
     185            [NSApp run]; 
     186            p_intf->b_die = VLC_TRUE; 
     187        } 
     188    } 
    168189#else 
    169190    if( p_intf->b_block ) 
     
    184205    else 
    185206    { 
    186 #endif 
    187207        /* Run the interface in a separate thread */ 
    188208        if( vlc_thread_create( p_intf, "interface", RunInterface, 
     
    193213        } 
    194214    } 
     215#endif 
    195216 
    196217    return VLC_SUCCESS; 
     
    419440    return VLC_SUCCESS; 
    420441} 
     442 
     443#ifdef SYS_DARWIN 
     444/***************************************************************************** 
     445 * VLCApplication implementation  
     446 *****************************************************************************/ 
     447@implementation VLCApplication  
     448 
     449- (void)stop: (id)sender 
     450{ 
     451    NSEvent *o_event; 
     452    NSAutoreleasePool *o_pool; 
     453    [super stop:sender]; 
     454 
     455    o_pool = [[NSAutoreleasePool alloc] init]; 
     456    /* send a dummy event to break out of the event loop */ 
     457    o_event = [NSEvent mouseEventWithType: NSLeftMouseDown 
     458                location: NSMakePoint( 1, 1 ) modifierFlags: 0 
     459                timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber] 
     460                context: [NSGraphicsContext currentContext] eventNumber: 1 
     461                clickCount: 1 pressure: 0.0]; 
     462    [NSApp postEvent: o_event atStart: YES]; 
     463    [o_pool release]; 
     464} 
     465 
     466- (void)terminate: (id)sender 
     467{ 
     468    if( [NSApp isRunning] ) 
     469        [NSApp stop:sender]; 
     470    [super terminate: sender]; 
     471} 
     472 
     473@end 
     474#endif 
     475 
  • src/libvlc.h

    r7f29318 re4ceccd  
    13171317    { NULL, 0, 0 } 
    13181318}; 
     1319 
  • src/misc/darwin_specific.m

    r25cd132 re4ceccd  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2004 VideoLAN 
    5  * $Id: darwin_specific.m,v 1.18 2004/01/06 12:02:06 zorglub Exp
     5 * $Id
    66 * 
    77 * Authors: Sam Hocevar <sam@zoy.org> 
  • src/video_output/video_output.c

    r7c92855 re4ceccd  
    11001100 ***************************************************************************** 
    11011101 * This function is called when the thread ends after a sucessful 
    1102  * initialization. It frees all ressources allocated by InitThread. 
     1102 * initialization. It frees all resources allocated by InitThread. 
    11031103 *****************************************************************************/ 
    11041104static void EndThread( vout_thread_t *p_vout ) 
  • src/vlc.c

    rbf680e8 re4ceccd  
    3636#   include <time.h>                                               /* time() */ 
    3737#endif 
    38 #ifdef HAVE_STRINGS_H 
    39 #   include <strings.h>                                         /* strncmp() */ 
    40 #endif 
    4138 
    4239#include <vlc/vlc.h> 
    43  
    44 #ifdef SYS_DARWIN 
    45 #include <Cocoa/Cocoa.h> 
    46 #endif 
    4740 
    4841/***************************************************************************** 
     
    5245static void SigHandler  ( int i_signal ); 
    5346#endif 
    54  
    55 #ifdef SYS_DARWIN 
    56 /***************************************************************************** 
    57  * VLCApplication interface 
    58  *****************************************************************************/ 
    59 @interface VLCApplication : NSApplication 
    60 { 
    61 } 
    62  
    63 @end 
    64  
    65 /***************************************************************************** 
    66  * VLCApplication implementation  
    67  *****************************************************************************/ 
    68 @implementation VLCApplication  
    69  
    70 - (void)stop: (id)sender 
    71 { 
    72     NSEvent *o_event; 
    73     [super stop:sender]; 
    74  
    75     /* send a dummy event to break out of the event loop */ 
    76     o_event = [NSEvent mouseEventWithType: NSLeftMouseDown 
    77                 location: NSMakePoint( 1, 1 ) modifierFlags: 0 
    78                 timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber] 
    79                 context: [NSGraphicsContext currentContext] eventNumber: 1 
    80                 clickCount: 1 pressure: 0.0]; 
    81     [NSApp postEvent: o_event atStart: YES]; 
    82 } 
    83  
    84 - (void)terminate: (id)sender 
    85 { 
    86     if( [NSApp isRunning] ) 
    87         [NSApp stop:sender]; 
    88     [super terminate: sender]; 
    89 } 
    90  
    91 @end 
    92  
    93 #endif /* SYS_DARWIN */ 
    9447 
    9548/***************************************************************************** 
     
    151104    } 
    152105 
    153 #ifdef HAVE_STRINGS_H 
    154     /* if first 3 chars of argv[0] are cli, then this is clivlc 
    155      * We detect this specifically for Mac OS X, so you can launch vlc 
    156      * from the commandline even if you are not logged in on the GUI */ 
    157     if( i_argc > 0 ) 
    158     { 
    159         char *psz_temp; 
    160         char *psz_program = psz_temp = ppsz_argv[0]; 
    161         while( *psz_temp ) 
    162         { 
    163             if( *psz_temp == '/' ) psz_program = ++psz_temp; 
    164             else ++psz_temp; 
    165         } 
    166         b_cli = !strncmp( psz_program, "cli", 3 ); 
    167     } 
    168 #endif 
    169  
    170 #ifdef SYS_DARWIN 
    171     if( !b_cli ) 
    172     { 
    173         [VLCApplication sharedApplication]; 
    174     } 
    175  
    176106    i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE ); 
    177      
    178     if( !b_cli ) 
    179     { 
    180         /* This is a blocking call */ 
    181         [NSApp run]; 
    182     } 
    183 #else 
    184     i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE ); 
    185 #endif /* SYS_DARWIN */ 
    186107 
    187108    /* Finish the threads */ 
     
    190111    /* Destroy the libvlc structure */ 
    191112    VLC_Destroy( 0 ); 
    192  
    193 #ifdef SYS_DARWIN 
    194     if( !b_cli ) 
    195     { 
    196         [NSApp terminate:NULL]; 
    197     } 
    198 #endif /* SYS_DARWIN */ 
    199113 
    200114    return i_ret;