Changeset 24ddff58f6fb99cafff56a88d2fb99a5f687ff51

Show
Ignore:
Timestamp:
26/03/08 17:36:07 (8 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1206549367 +0100
git-parent:

[5f84c2fc2138f2904321993f1d99772ae8648281]

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

libvlc: Move input_item array from playlist to libvlc.

This avoids the circular dependency there is from playlist and input item, which creates a dead lock at exit.

Files:

Legend:

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

    rdbdd540 r24ddff5  
    2727#endif 
    2828 
     29TYPEDEF_ARRAY(input_item_t*, input_item_array_t); 
     30 
    2931/***************************************************************************** 
    3032 * libvlc_internal_instance_t 
     
    4749 
    4850    vlc_object_t          *p_interaction;       ///< interface interaction object 
     51 
     52    /* There is no real reason to keep a list of items, but not to break 
     53     * everything, let's keep it */ 
     54    input_item_array_t    input_items;       ///< Array of all created input items 
     55    int                   i_last_input_id ;  ///< Last id of input item 
    4956 
    5057    /* Messages */ 
  • include/vlc_input.h

    rc90b3db r24ddff5  
    383383VLC_EXPORT( input_item_t *, input_ItemNewWithType, ( vlc_object_t *, const char *, const char *e, int, const char *const *, mtime_t i_duration, int ) ); 
    384384 
    385 VLC_EXPORT( input_item_t *, input_ItemGetById, (playlist_t *, int ) ); 
     385#define input_ItemGetById(a,b) __input_ItemGetById( VLC_OBJECT(a),b ) 
     386VLC_EXPORT( input_item_t *, __input_ItemGetById, (vlc_object_t *, int ) ); 
    386387 
    387388/***************************************************************************** 
  • include/vlc_playlist.h

    r5122c9d r24ddff5  
    4040 
    4141TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t); 
    42 TYPEDEF_ARRAY(input_item_t*, input_item_array_t); 
    4342 
    4443/** 
     
    177176    playlist_item_array_t all_items; /**< Array of items and nodes */ 
    178177 
    179     input_item_array_t    input_items; /**< Array of input items */ 
    180  
    181178    playlist_item_array_t current; /**< Items currently being played */ 
    182179    int                   i_current_index; /**< Index in current array */ 
     
    186183 
    187184    int                   i_last_playlist_id; /**< Last id to an item */ 
    188     int                   i_last_input_id ; /**< Last id on an input */ 
    189185 
    190186    /* Predefined items */ 
  • src/input/item.c

    rbf4a300 r24ddff5  
    105105    int i; 
    106106 
    107     playlist_t *p_playlist = pl_Yield( p_obj ); 
    108107    input_ItemClean( p_input ); 
    109108 
    110     ARRAY_BSEARCH( p_playlist->input_items,->i_id, int, p_input->i_id, i); 
     109    vlc_mutex_lock( &p_obj->p_libvlc->object_lock ); 
     110 
     111    ARRAY_BSEARCH( p_obj->p_libvlc->input_items,->i_id, int, p_input->i_id, i); 
    111112    if( i != -1 ) 
    112         ARRAY_REMOVE( p_playlist->input_items, i); 
    113  
    114     pl_Release( p_obj ); 
     113        ARRAY_REMOVE( p_obj->p_libvlc->input_items, i); 
     114 
     115    vlc_mutex_unlock( &p_obj->p_libvlc->object_lock ); 
     116 
    115117    free( p_input ); 
    116118} 
     
    216218} 
    217219 
    218 input_item_t *input_ItemGetById( playlist_t *p_playlist, int i_id ) 
    219 
     220input_item_t *__input_ItemGetById( vlc_object_t *p_obj, int i_id ) 
     221
     222    input_item_t * p_ret = NULL; 
    220223    int i; 
    221     ARRAY_BSEARCH( p_playlist->input_items, ->i_id, int, i_id, i); 
     224 
     225    vlc_mutex_lock( &p_obj->p_libvlc->object_lock ); 
     226 
     227    ARRAY_BSEARCH( p_obj->p_libvlc->input_items, ->i_id, int, i_id, i); 
    222228    if( i != -1 ) 
    223         return ARRAY_VAL( p_playlist->input_items, i); 
    224     return NULL; 
     229        p_ret = ARRAY_VAL( p_obj->p_libvlc->input_items, i); 
     230 
     231    vlc_mutex_unlock( &p_obj->p_libvlc->object_lock ); 
     232 
     233    return p_ret; 
    225234} 
    226235 
     
    244253                                int i_type ) 
    245254{ 
    246     playlist_t *p_playlist = pl_Yield( p_obj ); 
    247255    DECMALLOC_NULL( p_input, input_item_t ); 
    248256 
     
    250258    vlc_gc_init( p_input, input_ItemDestroy, (void *)p_obj ); 
    251259 
    252     PL_LOCK; 
    253     p_input->i_id = ++p_playlist->i_last_input_id; 
    254     ARRAY_APPEND( p_playlist->input_items, p_input ); 
    255     PL_UNLOCK; 
    256     pl_Release( p_obj ); 
     260    vlc_mutex_lock( &p_obj->p_libvlc->object_lock ); 
     261    p_input->i_id = ++p_obj->p_libvlc->i_last_input_id; 
     262    ARRAY_APPEND( p_obj->p_libvlc->input_items, p_input ); 
     263    vlc_mutex_unlock( &p_obj->p_libvlc->object_lock ); 
    257264 
    258265    p_input->b_fixed_name = VLC_FALSE; 
  • src/libvlc-common.c

    rdbdd540 r24ddff5  
    727727    p_libvlc->pp_timers = NULL; 
    728728 
     729    /* Init the array that holds every input item */ 
     730    ARRAY_INIT( p_libvlc->input_items ); 
     731    p_libvlc->i_last_input_id = 0; 
     732 
    729733    /* 
    730734     * Initialize hotkey handling 
     
    967971        announce_HandlerDestroy( p_announce ); 
    968972    } 
     973 
     974    msg_Dbg( p_libvlc, "removing remaining input items" ); 
     975    FOREACH_ARRAY( input_item_t *p_del, p_libvlc->input_items ) 
     976        msg_Dbg( p_libvlc, "WARNING: %p input item has not been deleted properly", p_del ); 
     977        input_ItemClean( p_del ); 
     978        free( p_del ); 
     979    FOREACH_END(); 
     980    ARRAY_RESET( p_libvlc->input_items ); 
     981 
    969982    return VLC_SUCCESS; 
    970983} 
  • src/libvlc.sym

    r6c52c72 r24ddff5  
    131131input_ItemAddInfo 
    132132input_ItemAddOpt 
    133 input_ItemGetById 
     133__input_ItemGetById 
    134134input_ItemGetInfo 
    135135__input_ItemNewExt 
  • src/playlist/engine.c

    r624a1e2 r24ddff5  
    8181    vlc_mutex_init( p_playlist, &p_playlist->gc_lock ); 
    8282    p_playlist->i_last_playlist_id = 0; 
    83     p_playlist->i_last_input_id = 0; 
    8483    p_playlist->p_input = NULL; 
    8584 
     
    8988    ARRAY_INIT( p_playlist->items ); 
    9089    ARRAY_INIT( p_playlist->all_items ); 
    91     ARRAY_INIT( p_playlist->input_items ); 
    9290    ARRAY_INIT( p_playlist->current ); 
    9391 
     
    492490    FOREACH_END(); 
    493491    ARRAY_RESET( p_playlist->all_items ); 
    494  
    495     FOREACH_ARRAY( input_item_t *p_del, p_playlist->input_items ) 
    496         input_ItemClean( p_del ); 
    497         free( p_del ); 
    498     FOREACH_END(); 
    499     ARRAY_RESET( p_playlist->input_items ); 
    500492 
    501493    ARRAY_RESET( p_playlist->items );