Changeset a8fe5f4ab123b90a557d5d7a4172d19325929367

Show
Ignore:
Timestamp:
07/05/08 02:42:10 (2 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1215218530 +0200
git-parent:

[68649ad4035bd2402566e347c2d100028553d327]

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

interface: Make sure that when b_should_run_on_first_thread is set the interface gets killed by vlc_object_kill( p_libvlc ).

This fixes Ctrl-C on Mac OS X.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/interface/interface.c

    r17e4415 ra8fe5f4  
    5151 *****************************************************************************/ 
    5252static void RunInterface( intf_thread_t *p_intf ); 
     53static void MonitorLibVLCDeath( intf_thread_t *p_intf ); 
    5354 
    5455static int AddIntfCallback( vlc_object_t *, char const *, 
     
    140141    if( p_intf->b_should_run_on_first_thread ) 
    141142    { 
     143        if( vlc_thread_create( p_intf, "interface", MonitorLibVLCDeath, 
     144                               VLC_THREAD_PRIORITY_LOW, false ) ) 
     145        { 
     146            msg_Err( p_intf, "cannot spawn libvlc death monitoring thread" ); 
     147            return VLC_EGENERIC; 
     148        } 
    142149        RunInterface( p_intf ); 
    143150        vlc_object_detach( p_intf ); 
     
    241248} 
    242249 
     250/***************************************************************************** 
     251 * MonitorLibVLCDeath: Used when b_should_run_on_first_thread is set. 
     252 *****************************************************************************/ 
     253static void MonitorLibVLCDeath( intf_thread_t *p_intf ) 
     254{ 
     255    libvlc_int_t * p_libvlc = p_intf->p_libvlc; 
     256    vlc_object_lock( p_libvlc ); 
     257    while(vlc_object_alive( p_libvlc ) ) 
     258        vlc_object_wait( p_libvlc ); 
     259    vlc_object_unlock( p_libvlc ); 
     260 
     261    /* Someone killed libvlc */ 
     262 
     263    /* Make sure we kill all interface objects, especially 
     264     * those that are blocking libvlc (running on main thread) */ 
     265    vlc_list_t * p_list = vlc_list_find( p_libvlc, VLC_OBJECT_INTF, FIND_CHILD ); 
     266    for( int i = 0; i < p_list->i_count; i++ ) 
     267    { 
     268        vlc_object_t * p_intf = p_list->p_values[i].p_object; 
     269        vlc_object_kill( p_intf ); 
     270    } 
     271    vlc_list_release( p_list ); 
     272 
     273} 
     274 
    243275static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd, 
    244276                         vlc_value_t oldval, vlc_value_t newval, void *p_data )