Changeset a06213d7f406c886dba790418ef8cca43d7ad140

Show
Ignore:
Timestamp:
09/24/06 11:34:57 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1159090497 +0000
git-parent:

[ade29e262f65904c0b95d2849680efd8d105dd43]

git-author:
Clément Stenac <zorglub@videolan.org> 1159090497 +0000
Message:

* Get rid of the Manager thread by making blocking interfaces listen to

p_libvlc->b_die
Not implemented for OS X as I am not sure, please check if it is feasible.

* Don't run the dummy interface

Files:

Legend:

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

    r19f019c ra06213d  
    120120VLC_EXPORT( void,              intf_Destroy,    ( intf_thread_t * ) ); 
    121121 
     122/* If the interface is in the main thread, it should listen both to 
     123 * p_intf->b_die and p_libvlc->b_die */ 
     124#define intf_ShouldDie( p_intf ) (p_intf->b_die || (p_intf->b_block && p_intf->p_libvlc->b_die ) ) 
     125 
    122126/*@}*/ 
    123127 
  • modules/control/corba/corba.c

    rb5243c8 ra06213d  
    758758        return FALSE; 
    759759    } 
    760    
     760 
    761761    vlc_mutex_lock( &p_intf->change_lock ); 
    762762 
    763763    if( b_work_pending ) 
    764764        CORBA_ORB_perform_work( p_intf->p_sys->orb, ev ); 
    765    
    766     if( p_intf->b_die
     765 
     766    if( intf_ShouldDie( p_intf )
    767767    { 
    768768        vlc_mutex_unlock( &p_intf->change_lock ); 
  • modules/control/gestures.c

    rf485214 ra06213d  
    156156 
    157157    /* Main loop */ 
    158     while( !p_intf->b_die
     158    while( !intf_ShouldDie( p_intf )
    159159    { 
    160160        vlc_mutex_lock( &p_intf->change_lock ); 
     
    262262    char *psz_button; 
    263263    /* we might need some locking here */ 
    264     if( !p_intf->b_die
     264    if( !intf_ShouldDie( p_intf )
    265265    { 
    266266        input_thread_t * p_input; 
  • modules/control/hotkeys.c

    r360b392 ra06213d  
    165165    } 
    166166 
    167     while( !p_intf->b_die
     167    while( !intf_ShouldDie( p_intf )
    168168    { 
    169169        int i_key, i_action; 
  • modules/control/http/http.c

    rf485214 ra06213d  
    432432    intf_sys_t     *p_sys = p_intf->p_sys; 
    433433 
    434     while( !p_intf->b_die
     434    while( !intf_ShouldDie( p_intf )
    435435    { 
    436436        /* get the playlist */ 
  • modules/control/lirc.c

    rf485214 ra06213d  
    121121    char *code, *c; 
    122122 
    123     while( !p_intf->b_die
     123    while( !intf_ShouldDie( p_intf )
    124124    { 
    125125        /* Sleep a bit */ 
     
    137137        } 
    138138 
    139         while( !p_intf->b_die 
     139        while( !intf_ShouldDie( p_intf ) 
    140140                && lirc_code2char( p_intf->p_sys->config, code, &c ) == 0 
    141141                && c != NULL ) 
  • modules/control/motion.c

    r2cda7c1 ra06213d  
    133133    int i_x, i_oldx = 0; 
    134134 
    135     while( !p_intf->b_die
     135    while( !intf_ShouldDie( p_intf )
    136136    { 
    137137#define LOW_THRESHOLD 80 
  • modules/control/netsync.c

    rb0639d9 ra06213d  
    160160    vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_INPUT ); 
    161161 
    162     while( !p_intf->b_die
     162    while( !intf_ShouldDie( p_intf )
    163163    { 
    164164        struct timeval timeout; 
  • modules/control/rc.c

    r415749b ra06213d  
    561561#endif 
    562562 
    563     while( !p_intf->b_die
     563    while( !intf_ShouldDie( p_intf )
    564564    { 
    565565        char *psz_cmd, *psz_arg; 
     
    22022202                                INTF_IDLE_SLEEP/1000 ) == WAIT_OBJECT_0 ) 
    22032203    { 
    2204         while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH && 
     2204        while( !intf_ShouldDie( p_intf ) && *pi_size < MAX_LINE_LENGTH && 
    22052205               ReadConsoleInput( p_intf->p_sys->hConsoleIn, &input_record, 
    22062206                                 1, &i_dw ) ) 
     
    22722272#endif 
    22732273 
    2274     while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH && 
     2274    while( !intf_ShouldDie( p_intf ) && *pi_size < MAX_LINE_LENGTH && 
    22752275           (i_read = net_ReadNonBlock( p_intf, p_intf->p_sys->i_socket == -1 ? 
    22762276                       0 /*STDIN_FILENO*/ : p_intf->p_sys->i_socket, NULL, 
  • modules/control/showintf.c

    r415749b ra06213d  
    117117 
    118118    /* Main loop */ 
    119     while( !p_intf->b_die
     119    while( !intf_ShouldDie( p_intf )
    120120    { 
    121121        vlc_mutex_lock( &p_intf->change_lock ); 
     
    176176static int InitThread( intf_thread_t * p_intf ) 
    177177{ 
    178     if( !p_intf->b_die
     178    if( !intf_ShouldDie( p_intf )
    179179    { 
    180180        vlc_mutex_lock( &p_intf->change_lock ); 
  • modules/control/telnet.c

    rf485214 ra06213d  
    246246    psz_password = config_GetPsz( p_intf, "telnet-password" ); 
    247247 
    248     while( !p_intf->b_die
     248    while( !intf_ShouldDie( p_intf )
    249249    { 
    250250        fd_set fds_read, fds_write; 
  • modules/gui/beos/Interface.cpp

    r2cb472d ra06213d  
    120120static void Run( intf_thread_t *p_intf ) 
    121121{ 
    122     while( !p_intf->b_die
     122    while( !intf_ShouldDie( p_intf )
    123123    { 
    124124        p_intf->p_sys->p_window->UpdateInterface(); 
  • modules/gui/macosx/intf.m

    r0b66060 ra06213d  
    10071007    vlc_object_release( p_playlist ); 
    10081008 
    1009     while( !p_intf->b_die
     1009    while( !intf_ShouldDie( p_intf )
    10101010    { 
    10111011        vlc_mutex_lock( &p_intf->change_lock ); 
  • modules/gui/ncurses.c

    rf485214 ra06213d  
    337337    t_last_refresh = ( time( 0 ) - 1); 
    338338 
    339     while( !p_intf->b_die
     339    while( !intf_ShouldDie( p_intf )
    340340    { 
    341341        msleep( INTF_IDLE_SLEEP ); 
  • modules/gui/pda/pda.c

    rf485214 ra06213d  
    320320#ifdef NEED_GTK2_MAIN 
    321321    msg_Dbg( p_intf, "Manage GTK keyboard events using threads" ); 
    322     while( !p_intf->b_die
     322    while( !intf_ShouldDie( p_intf )
    323323    { 
    324324        Manage( p_intf ); 
     
    519519        vlc_mutex_unlock( &p_input->object_lock ); 
    520520    } 
    521     else if( p_intf->p_sys->b_playing && !p_intf->b_die
     521    else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf )
    522522    { 
    523523        E_(GtkModeManage)( p_intf ); 
     
    526526 
    527527#ifndef NEED_GTK2_MAIN 
    528     if( p_intf->b_die
     528    if( intf_ShouldDie( p_intf )
    529529    { 
    530530        vlc_mutex_unlock( &p_intf->change_lock ); 
  • modules/gui/qt4/main_interface.cpp

    r18efcf5 ra06213d  
    622622    advControls->enableVideo( THEMIM->getIM()->hasVideo() ); 
    623623 
    624     if( p_intf->b_die
     624    if( intf_ShouldDie( p_intf )
    625625    { 
    626626        QApplication::closeAllWindows(); 
  • modules/gui/skins2/src/vlcproc.cpp

    rf485214 ra06213d  
    231231{ 
    232232    // Did the user request to quit vlc ? 
    233     if( getIntf()->b_die || getIntf()->p_libvlc->b_die
     233    if( intf_ShouldDie( getIntf() )
    234234    { 
    235235        CmdQuit *pCmd = new CmdQuit( getIntf() ); 
  • modules/gui/wince/timer.cpp

    r2cb472d ra06213d  
    211211        } 
    212212    } 
    213     else if( p_intf->p_sys->b_playing && !p_intf->b_die
     213    else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf )
    214214    { 
    215215        p_intf->p_sys->b_playing = 0; 
     
    218218    } 
    219219 
    220     if( p_intf->b_die
     220    if( intf_ShouldDie( p_intf )
    221221    { 
    222222        vlc_mutex_unlock( &p_intf->change_lock ); 
  • modules/gui/wxwidgets/timer.cpp

    r2cb472d ra06213d  
    108108    } 
    109109 
    110     if( p_intf->b_die
     110    if( intf_ShouldDie( p_intf )
    111111    { 
    112112        vlc_mutex_unlock( &p_intf->change_lock ); 
  • modules/misc/dummy/interface.c

    r07b1471 ra06213d  
    5252    msg_Info( p_intf, "using the dummy interface module..." ); 
    5353 
    54     p_intf->pf_run = Run
     54    p_intf->pf_run = NULL
    5555 
    5656    return VLC_SUCCESS; 
    5757} 
    58  
    59 /***************************************************************************** 
    60  * Run: main loop 
    61  *****************************************************************************/ 
    62 static void Run( intf_thread_t *p_intf ) 
    63 { 
    64     while( !p_intf->b_die ) 
    65     { 
    66         /* Wait a bit */ 
    67         msleep( INTF_IDLE_SLEEP ); 
    68     } 
    69 } 
    70  
  • src/interface/interface.c

    r187a6ea ra06213d  
    5353 * Local prototypes 
    5454 *****************************************************************************/ 
    55 static void Manager( intf_thread_t *p_intf ); 
    5655static void RunInterface( intf_thread_t *p_intf ); 
    5756 
     
    6261 
    6362#ifdef __APPLE__ 
     63static void Manager( intf_thread_t *p_intf ); 
    6464/***************************************************************************** 
    6565 * VLCApplication interface 
     
    189189        /* This interface doesn't need to be run */ 
    190190        if( !p_intf->pf_run ) 
    191         { 
    192191            return VLC_SUCCESS; 
    193         } 
     192 
    194193        /* Run the interface in a separate thread */ 
    195194        if( !strcmp( p_intf->p_module->psz_object_name, "macosx" ) ) 
     
    217216    if( p_intf->b_block ) 
    218217    { 
    219         /* Run a manager thread, launch the interface, kill the manager */ 
    220         if( vlc_thread_create( p_intf, "manager", Manager, 
    221                                VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) 
    222         { 
    223             msg_Err( p_intf, "cannot spawn manager thread" ); 
    224             return VLC_EGENERIC; 
    225         } 
    226  
    227         RunInterface( p_intf ); 
    228  
     218        /* If the main interface does not have a run function, 
     219        * implement a waiting loop ourselves 
     220         */ 
     221        if( p_intf->pf_run ) 
     222            RunInterface( p_intf ); 
     223        else 
     224        { 
     225            while( !intf_ShouldDie( p_intf ) ) 
     226                msleep( INTF_IDLE_SLEEP * 2); 
     227        } 
    229228        p_intf->b_die = VLC_TRUE; 
    230229        /* Do not join the thread... intf_StopThread will do it for us */ 
     
    262261    { 
    263262        p_intf->b_die = VLC_TRUE; 
    264     } 
    265  
    266     /* Wait for the thread to exit */ 
    267     if( p_intf->pf_run ) 
    268         vlc_thread_join( p_intf ); 
     263        if( p_intf->pf_run ) 
     264            vlc_thread_join( p_intf ); 
     265    } 
    269266} 
    270267 
     
    294291 
    295292/***************************************************************************** 
    296  * Manager: helper thread for blocking interfaces 
    297  ***************************************************************************** 
    298  * If the interface is launched in the main thread, it will not listen to 
    299  * p_vlc->b_die events because it is only supposed to listen to p_intf->b_die. 
    300  * This thread takes care of the matter. 
    301  *****************************************************************************/ 
    302 /** 
    303  * \brief Helper thread for blocking interfaces. 
    304  * \ingroup vlc_interface 
    305  * 
    306  * This is a local function 
    307  * If the interface is launched in the main thread, it will not listen to 
    308  * p_vlc->b_die events because it is only supposed to listen to p_intf->b_die. 
    309  * This thread takes care of the matter. 
    310  * \see intf_RunThread 
    311  * \param p_intf an interface thread 
    312  * \return nothing 
    313  */ 
     293 * Manager: helper thread for blocking OS X 
     294 *****************************************************************************/ 
     295#ifdef __APPLE__ 
    314296static void Manager( intf_thread_t *p_intf ) 
    315297{ 
     
    321303        { 
    322304            p_intf->b_die = VLC_TRUE; 
    323 #ifdef __APPLE__ 
    324     if( strncmp( p_intf->p_libvlc->psz_object_name, "clivlc", 6 ) ) 
    325     { 
    326         [NSApp stop: NULL]; 
    327     } 
    328 #endif 
     305            if( strncmp( p_intf->p_libvlc->psz_object_name, "clivlc", 6 ) ) 
     306            { 
     307                [NSApp stop: NULL]; 
     308            } 
    329309            return; 
    330310        } 
    331311    } 
    332312} 
     313#endif 
    333314 
    334315/*****************************************************************************