Changeset f452c11004a9eddf5fa3c9342b44590c936018a1

Show
Ignore:
Timestamp:
10/18/07 17:34:01 (11 months ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1192721641 +0000
git-parent:

[fbce9b9638ce65acc8c4c8bb1c9d7405d4378bc8]

git-author:
Rafaël Carré <funman@videolan.org> 1192721641 +0000
Message:

playlist_CreateNode(): add an argument to specify an input_item_t to be linked with the node, rather than creating a new input.
Setting that argument to NULL will make playlist_CreateNode() behave like previously.

That way we can create only one input per pair of node (for local playlist, media library, and service discovery)
Previous behaviour was to create 2 inputs with the same i_id member, but we would store both input in a binary search tree (sorted by i_id), and that kind of tree MUST NOT have 2 items with the same key, else we will get some bad memory corruption when the wrong input is removed from the tree (the other being left in the tree while the memory referred by it was freed).
Note that this breaks ABI

Files:

Legend:

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

    r222960c rf452c11  
    392392 
    393393/* Node management */ 
    394 VLC_EXPORT( playlist_item_t *, playlist_NodeCreate, ( playlist_t *, const char *, playlist_item_t * p_parent, int i_flags ) ); 
     394VLC_EXPORT( playlist_item_t *, playlist_NodeCreate, ( playlist_t *, const char *, playlist_item_t * p_parent, int i_flags, input_item_t * ) ); 
    395395VLC_EXPORT( int, playlist_NodeAppend, (playlist_t *,playlist_item_t*,playlist_item_t *) ); 
    396396VLC_EXPORT( int, playlist_NodeInsert, (playlist_t *,playlist_item_t*,playlist_item_t *, int) ); 
  • modules/access/directory.c

    rd8fc0a9 rf452c11  
    477477                p_node = playlist_NodeCreate( p_playlist, entry, 
    478478                                              p_parent_category, 
    479                                               PLAYLIST_NO_REBUILD ); 
     479                                              PLAYLIST_NO_REBUILD, NULL ); 
    480480 
    481481                /* If we had the parent in category, the it is now node. 
  • modules/gui/macosx/playlist.m

    ra0bac60 rf452c11  
    13741374    if( psz_name != NULL && psz_name != "" ) 
    13751375        p_item = playlist_NodeCreate( p_playlist, psz_name, 
    1376                                             p_playlist->p_local_category, 0 ); 
     1376                                      p_playlist->p_local_category, 0, NULL ); 
    13771377    else if(! config_GetInt( p_playlist, "interact" ) ) 
    13781378    { 
    13791379        /* in case that the interaction is disabled, just give it a bogus name */ 
    13801380        p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"), 
    1381                                             p_playlist->p_local_category, 0 ); 
     1381                                      p_playlist->p_local_category, 0, NULL ); 
    13821382    } 
    13831383 
  • modules/gui/wxwidgets/dialogs/playlist.cpp

    r02fbd58 rf452c11  
    16061606    p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id, VLC_TRUE ); 
    16071607 
    1608     playlist_NodeCreate( p_playlist, psz_name, p_item, 0 ); 
     1608    playlist_NodeCreate( p_playlist, psz_name, p_item, 0, NULL ); 
    16091609 
    16101610    UnlockPlaylist( p_intf->p_sys, p_playlist ); 
  • modules/services_discovery/upnp_cc.cpp

    r83a9495 rf452c11  
    181181    char *str = strdup( dev->getFriendlyName( ) ); 
    182182 
    183     p_item = playlist_NodeCreate( p_playlist, str, p_sd->p_cat,0 ); 
     183    p_item = playlist_NodeCreate( p_playlist, str, p_sd->p_cat, 0, NULL ); 
    184184    p_item->i_flags &= ~PLAYLIST_SKIP_FLAG; 
    185185    msg_Dbg( p_sd, "device %s added", str ); 
     
    222222 
    223223        char* p_name = strdup(title); /* See other comment on strdup */ 
    224         playlist_item_t* p_node = playlist_NodeCreate( p_playlist, 
    225                                                        p_name, p_parent, 0 ); 
     224        playlist_item_t* p_node = playlist_NodeCreate( p_playlist, p_name, 
     225                                                       p_parent, 0, NULL ); 
    226226        free(p_name); 
    227227 
  • modules/services_discovery/upnp_intel.cpp

    rbe8dfea rf452c11  
    854854 
    855855        char* title = strdup( container->getTitle() ); 
    856         playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode, 0 ); 
     856        playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode, 0, NULL ); 
    857857        free( title ); 
    858858 
     
    917917    playlist_item_t* node = playlist_NodeCreate( pl_Get( _cookie->serviceDiscovery ), 
    918918                                                 name, 
    919                                           _cookie->serviceDiscovery->p_sys->p_node_cat, 0 ); 
     919                                          _cookie->serviceDiscovery->p_sys->p_node_cat, 0, NULL ); 
    920920    free( name ); 
    921921    s->setPlaylistNode( node ); 
  • src/playlist/engine.c

    r47cbfa6 rf452c11  
    101101 
    102102    p_playlist->p_root_category = playlist_NodeCreate( p_playlist, NULL, NULL, 
    103                                                        0 ); 
     103                                    0, NULL ); 
    104104    p_playlist->p_root_onelevel = playlist_NodeCreate( p_playlist, NULL, NULL, 
    105                                                        0 ); 
     105                                    0, p_playlist->p_root_category->p_input ); 
    106106 
    107107    if( !p_playlist->p_root_category || !p_playlist->p_root_onelevel ) 
     
    109109 
    110110    /* Create playlist and media library */ 
    111     p_playlist->p_local_category = playlist_NodeCreate( p_playlist
    112                               _( "Playlist" ),p_playlist->p_root_category, 0 ); 
    113     p_playlist->p_local_onelevel =  playlist_NodeCreate( p_playlist, 
    114                               _( "Playlist" ), p_playlist->p_root_onelevel, 0 ); 
     111    playlist_NodesPairCreate( p_playlist, _( "Playlist" )
     112                            &p_playlist->p_local_category, 
     113                            &p_playlist->p_local_onelevel, VLC_FALSE ); 
     114 
    115115    p_playlist->p_local_category->i_flags |= PLAYLIST_RO_FLAG; 
    116116    p_playlist->p_local_onelevel->i_flags |= PLAYLIST_RO_FLAG; 
     
    121121        return NULL; 
    122122 
    123     /* Link the nodes together. Todo: actually create them from the same input*/ 
    124     p_playlist->p_local_onelevel->p_input->i_id = 
    125         p_playlist->p_local_category->p_input->i_id; 
    126  
    127123    if( config_GetInt( p_playlist, "media-library") ) 
    128124    { 
    129         p_playlist->p_ml_category =   playlist_NodeCreate( p_playlist, 
    130                          _( "Media Library" ), p_playlist->p_root_category, 0 ); 
    131         p_playlist->p_ml_onelevel =  playlist_NodeCreate( p_playlist, 
    132                          _( "Media Library" ), p_playlist->p_root_onelevel, 0 ); 
     125        playlist_NodesPairCreate( p_playlist, _( "Media Library" ), 
     126                            &p_playlist->p_ml_category, 
     127                            &p_playlist->p_ml_onelevel, VLC_FALSE ); 
    133128 
    134129        if(!p_playlist->p_ml_category || !p_playlist->p_ml_onelevel) 
     
    137132        p_playlist->p_ml_category->i_flags |= PLAYLIST_RO_FLAG; 
    138133        p_playlist->p_ml_onelevel->i_flags |= PLAYLIST_RO_FLAG; 
    139         p_playlist->p_ml_onelevel->p_input->i_id = 
    140              p_playlist->p_ml_category->p_input->i_id; 
    141  
    142134    } 
    143135    else 
  • src/playlist/services_discovery.c

    r0a74125 rf452c11  
    208208        { 
    209209            p_cat = playlist_NodeCreate( p_parent->p_playlist, psz_cat, 
    210                                          p_parent, 0 ); 
     210                                         p_parent, 0, NULL ); 
    211211            p_cat->i_flags &= ~PLAYLIST_SKIP_FLAG; 
    212212        } 
  • src/playlist/tree.c

    rd6b07ef rf452c11  
    4848 * \param p_parent the parent node to attach to or NULL if no attach 
    4949 * \param p_flags miscellaneous flags 
     50 * \param p_input the input_item to attach to or NULL if it has to be created 
    5051 * \return the new node 
    5152 */ 
    5253playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist, 
    5354                                       const char *psz_name, 
    54                                        playlist_item_t *p_parent, int i_flags ) 
    55 
    56     input_item_t *p_input; 
     55                                       playlist_item_t *p_parent, int i_flags, 
     56                                       input_item_t *p_input ) 
     57
     58    input_item_t *p_new_input; 
    5759    playlist_item_t *p_item; 
    5860 
    5961    if( !psz_name ) psz_name = _("Undefined"); 
    60     p_input = input_ItemNewWithType( VLC_OBJECT(p_playlist), NULL, psz_name, 
    61                                      0, NULL, -1, ITEM_TYPE_NODE ); 
    62     p_item = playlist_ItemNewFromInput( VLC_OBJECT(p_playlist), p_input ); 
     62 
     63    if( !p_input ) 
     64        p_new_input = input_ItemNewWithType( VLC_OBJECT(p_playlist), NULL, 
     65                                        psz_name, 0, NULL, -1, ITEM_TYPE_NODE ); 
     66    p_item = playlist_ItemNewFromInput( VLC_OBJECT(p_playlist), 
     67                                        p_input ? p_input : p_new_input ); 
    6368 
    6469    if( p_item == NULL )  return NULL; 
     
    280285/** 
    281286 * Create a pair of nodes in the category and onelevel trees. 
    282  * They share the same input ID. 
    283  * \todo really share the input item 
     287 * They share the same input item. 
    284288 * \param p_playlist the playlist 
    285289 * \param psz_name the name of the nodes 
     
    294298{ 
    295299    *pp_node_cat = playlist_NodeCreate( p_playlist, psz_name, 
    296                                         p_playlist->p_root_category, 0 ); 
     300                                        p_playlist->p_root_category, 0, NULL ); 
    297301    *pp_node_one = playlist_NodeCreate( p_playlist, psz_name, 
    298                                         p_playlist->p_root_onelevel, 0 ); 
    299     (*pp_node_one)->p_input->i_id = (*pp_node_cat)->p_input->i_id
     302                                        p_playlist->p_root_onelevel, 0, 
     303                                        (*pp_node_cat)->p_input )
    300304    if( b_for_sd ) 
    301305    {