Changeset 6ecd4022a3d284f86f1ee632952aa81b8157d17f

Show
Ignore:
Timestamp:
16/09/06 00:10:37 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1158358237 +0000
git-parent:

[3f99651d8fa1356203faf67103e1c500d3b30e16]

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

Remove vlc_object_find for playlist from the core

Files:

Legend:

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

    r28d49d9 r6ecd402  
    2525#define _VLC_PLAYLIST_H_ 
    2626 
     27#include <assert.h> 
     28 
    2729/** 
    2830 *  \file 
     
    208210#define PL_LOCK vlc_mutex_lock( &p_playlist->object_lock ); 
    209211#define PL_UNLOCK vlc_mutex_unlock( &p_playlist->object_lock ); 
     212 
     213#define pl_Get( a ) a->p_libvlc->p_playlist 
     214#define pl_Yield( a ) __pl_Yield( VLC_OBJECT(a) ) 
     215static inline playlist_t *__pl_Yield( vlc_object_t *p_this ) 
     216{ 
     217    assert( p_this->p_libvlc->p_playlist ); 
     218    vlc_object_yield( p_this->p_libvlc->p_playlist ); 
     219    return p_this->p_libvlc->p_playlist; 
     220} 
     221#define pl_Release(a) vlc_object_release( a->p_libvlc->p_playlist ); 
    210222 
    211223/* Playlist control */ 
  • src/input/control.c

    r83f23b6 r6ecd402  
    531531static void NotifyPlaylist( input_thread_t *p_input ) 
    532532{ 
    533     playlist_t *p_playlist = 
    534         (playlist_t *)vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, 
    535                                        FIND_PARENT ); 
    536     if( p_playlist ) 
    537     { 
    538         var_SetInteger( p_playlist, "item-change", 
    539                         p_input->input.p_item->i_id ); 
    540         vlc_object_release( p_playlist ); 
    541     } 
     533    playlist_t *p_playlist = pl_Yield( p_input ); 
     534    var_SetInteger( p_playlist, "item-change", 
     535                    p_input->input.p_item->i_id ); 
     536    pl_Release( p_input ); 
    542537} 
    543538 
  • src/input/input.c

    r8923568 r6ecd402  
    11361136    if( p_input->p_sout ) 
    11371137    { 
    1138         vlc_object_t *p_pl = 
    1139             vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
    11401138        vlc_value_t keep; 
    11411139 
     
    11461144        vlc_mutex_unlock( &p_input->counters.counters_lock ); 
    11471145 
    1148         if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool && p_pl
     1146        if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool
    11491147        { 
    11501148            /* attach sout to the playlist */ 
    11511149            msg_Dbg( p_input, "keeping sout" ); 
    11521150            vlc_object_detach( p_input->p_sout ); 
    1153             vlc_object_attach( p_input->p_sout, p_pl ); 
     1151            vlc_object_attach( p_input->p_sout, p_input->p_libvlc->p_playlist ); 
    11541152        } 
    11551153        else 
     
    11581156            sout_DeleteInstance( p_input->p_sout ); 
    11591157        } 
    1160         if( p_pl ) 
    1161             vlc_object_release( p_pl ); 
    11621158    } 
    11631159 
     
    18251821                              vlc_bool_t b_quick ) 
    18261822{ 
    1827     playlist_t *p_playlist; 
    18281823    char psz_buffer[MSTRTIME_MAX_SIZE]; 
    18291824 
     
    18321827    vlc_mutex_unlock( &p_input->input.p_item->lock ); 
    18331828 
    1834         p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, 
    1835                                                FIND_PARENT); 
    1836     if( p_playlist ) 
    1837     { 
    1838         var_SetInteger( p_playlist, "item-change", 
    1839                         p_input->input.p_item->i_id ); 
    1840         vlc_object_release( p_playlist ); 
    1841     } 
     1829    pl_Yield( p_input ); 
     1830    var_SetInteger( pl_Get( p_input ), "item-change", 
     1831                    p_input->input.p_item->i_id ); 
     1832    pl_Release( p_input ) 
    18421833 
    18431834    input_Control( p_input, INPUT_ADD_INFO, _("General"), _("Duration"), 
  • src/input/item.c

    r3f1e3ab r6ecd402  
    7171{ 
    7272    vlc_object_t *p_obj = (vlc_object_t *)p_this->p_destructor_arg; 
     73    input_item_t *p_input = (input_item_t *) p_this; 
    7374    int i; 
    74     input_item_t *p_input = (input_item_t *) p_this; 
    75  
    76     playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_obj, 
    77                                           VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
    78  
     75 
     76    playlist_t *p_playlist = pl_Yield( p_obj ); 
    7977    vlc_input_item_Clean( p_input ); 
    8078 
    81     if( p_playlist ) 
    82     { 
    83         for( i = 0 ; i< p_playlist->i_input_items ; i++ ) 
    84         { 
    85             if( p_playlist->pp_input_items[i]->i_id == p_input->i_id ) 
    86             { 
    87                 REMOVE_ELEM( p_playlist->pp_input_items, 
    88                              p_playlist->i_input_items, i ); 
    89                 break; 
    90             } 
    91         } 
    92         vlc_object_release( p_playlist ); 
    93     } 
     79    for( i = 0 ; i< p_playlist->i_input_items ; i++ ) 
     80    { 
     81        if( p_playlist->pp_input_items[i]->i_id == p_input->i_id ) 
     82        { 
     83            REMOVE_ELEM( p_playlist->pp_input_items, 
     84                         p_playlist->i_input_items, i ); 
     85            break; 
     86        } 
     87    } 
     88    pl_Release( p_obj ); 
    9489    free( p_input ); 
    9590} 
     
    209204                                int i_type ) 
    210205{ 
    211     /* FIXME DON'T SEARCH PLAYLIST */ 
    212     /* FIXME SHOULD LOCK */ 
    213     input_item_t *p_input = (input_item_t *)malloc( sizeof( input_item_t ) ); 
    214     playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_obj, 
    215                                 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
     206    playlist_t *p_playlist = pl_Yield( p_obj ); 
     207    DECMALLOC_NULL( p_input, input_item_t ); 
    216208 
    217209    vlc_input_item_Init( p_obj, p_input ); 
    218210    vlc_gc_init( p_input, vlc_input_item_Destroy, (void *)p_obj ); 
    219211 
     212    PL_LOCK; 
    220213    p_input->i_id = ++p_playlist->i_last_input_id; 
    221  
    222     INSERT_ELEM( p_playlist->pp_input_items, p_playlist->i_input_items, 
    223                  p_playlist->i_input_items, p_input ); 
    224     vlc_object_release( p_playlist ); 
     214    TAB_APPEND( p_playlist->i_input_items, 
     215                p_playlist->pp_input_items, 
     216                p_input ); 
     217    PL_UNLOCK; 
     218    pl_Release( p_obj ); 
    225219 
    226220    p_input->b_fixed_name = VLC_FALSE; 
  • src/interface/interaction.c

    r928454f r6ecd402  
    446446static interaction_t * InteractionGet( vlc_object_t *p_this ) 
    447447{ 
    448     playlist_t *p_playlist; 
    449448    interaction_t *p_interaction; 
    450  
    451     p_playlist = (playlist_t*) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, 
    452                                                 FIND_ANYWHERE ); 
    453     if( !p_playlist ) 
    454         return NULL; 
    455  
     449    playlist_t *p_playlist = pl_Yield( p_this ); 
     450 
     451    PL_LOCK; 
    456452    if( p_playlist->p_interaction == NULL ) 
    457453       InteractionInit( p_playlist ); 
    458454 
    459455    p_interaction = p_playlist->p_interaction; 
    460  
    461     vlc_object_release( p_playlist ); 
     456    PL_UNLOCK; 
     457 
     458    pl_Release( p_this ); 
    462459    return p_interaction; 
    463460} 
  • src/video_output/video_output.c

    r83f23b6 r6ecd402  
    115115    if( !p_fmt ) 
    116116    { 
    117         /* Reattach video output to input before bailing out */ 
     117        /* Reattach video output to playlist before bailing out */ 
    118118        if( p_vout ) 
    119119        { 
    120             vlc_object_t *p_playlist; 
    121  
    122             p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, 
    123                                           FIND_ANYWHERE ); 
    124  
    125             if( p_playlist ) 
    126             { 
    127                 spu_Attach( p_vout->p_spu, p_this, VLC_FALSE ); 
    128                 vlc_object_detach( p_vout ); 
    129                 vlc_object_attach( p_vout, p_playlist ); 
    130  
    131                 vlc_object_release( p_playlist ); 
    132             } 
    133             else 
    134             { 
    135                 msg_Dbg( p_this, "cannot find playlist, destroying vout" ); 
    136                 vlc_object_detach( p_vout ); 
    137                 vout_Destroy( p_vout ); 
    138             } 
     120            vlc_object_t *p_playlist = pl_Yield( p_this ); 
     121            spu_Attach( p_vout->p_spu, p_this, VLC_FALSE ); 
     122            vlc_object_detach( p_vout ); 
     123            vlc_object_attach( p_vout, p_playlist ); 
     124            pl_Release( p_this ); 
    139125        } 
    140126        return NULL; 
     
    152138        if( !p_vout ) 
    153139        { 
    154             playlist_t *p_playlist; 
    155  
    156             p_playlist = vlc_object_find( p_this, 
    157                                           VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
    158             if( p_playlist ) 
    159             { 
    160                 vlc_mutex_lock( &p_playlist->gc_lock ); 
    161                 p_vout = vlc_object_find( p_playlist, 
    162                                           VLC_OBJECT_VOUT, FIND_CHILD ); 
    163                 /* only first children of p_input for unused vout */ 
    164                 if( p_vout && p_vout->p_parent != (vlc_object_t *)p_playlist ) 
    165                 { 
    166                     vlc_object_release( p_vout ); 
    167                     p_vout = NULL; 
    168                 } 
    169                 vlc_mutex_unlock( &p_playlist->gc_lock ); 
    170                 vlc_object_release( p_playlist ); 
    171             } 
     140            playlist_t *p_playlist = pl_Yield( p_this ); 
     141            vlc_mutex_lock( &p_playlist->gc_lock ); 
     142            p_vout = vlc_object_find( p_playlist, 
     143                                      VLC_OBJECT_VOUT, FIND_CHILD ); 
     144            /* only first children of p_input for unused vout */ 
     145            if( p_vout && p_vout->p_parent != (vlc_object_t *)p_playlist ) 
     146            { 
     147                vlc_object_release( p_vout ); 
     148                p_vout = NULL; 
     149            } 
     150            vlc_mutex_unlock( &p_playlist->gc_lock ); 
    172151        } 
    173152    } 
     
    499478void vout_Destroy( vout_thread_t *p_vout ) 
    500479{ 
    501     vlc_object_t *p_playlist; 
     480    vout_thread_t *p_another_vout; 
     481    vlc_object_t *p_playlist = pl_Yield( p_vout ); 
    502482 
    503483    /* Request thread destruction */ 
     
    507487    var_Destroy( p_vout, "intf-change" ); 
    508488 
    509     p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, 
    510                                   FIND_ANYWHERE ); 
    511  
    512489    if( p_vout->psz_filter_chain ) free( p_vout->psz_filter_chain ); 
    513490 
     
    515492    vlc_object_destroy( p_vout ); 
    516493 
    517     /* If it was the last vout, tell the interface to show up */ 
    518     if( p_playlist != NULL ) 
    519     { 
    520         vout_thread_t *p_another_vout = vlc_object_find( p_playlist, 
    521                                             VLC_OBJECT_VOUT, FIND_ANYWHERE ); 
    522         if( p_another_vout == NULL ) 
    523         { 
    524             vlc_value_t val; 
    525             val.b_bool = VLC_TRUE; 
    526             var_Set( p_playlist, "intf-show", val ); 
    527         } 
    528         else 
    529         { 
    530             vlc_object_release( p_another_vout ); 
    531         } 
    532         vlc_object_release( p_playlist ); 
    533     } 
     494    p_another_vout = vlc_object_find( p_playlist, 
     495                                      VLC_OBJECT_VOUT, FIND_ANYWHERE ); 
     496    if( p_another_vout == NULL ) 
     497    { 
     498        vlc_value_t val; 
     499        val.b_bool = VLC_TRUE; 
     500        var_Set( p_playlist, "intf-show", val ); 
     501    } 
     502    else 
     503    { 
     504        vlc_object_release( p_another_vout ); 
     505    } 
     506    vlc_object_release( p_playlist ); 
    534507} 
    535508 
  • src/video_output/vout_intf.c

    rf485214 r6ecd402  
    11001100{ 
    11011101    vout_thread_t *p_vout = (vout_thread_t *)p_this; 
    1102     playlist_t *p_playlist
     1102    playlist_t *p_playlist = pl_Yield( p_this )
    11031103    vout_Control( p_vout, VOUT_SET_STAY_ON_TOP, newval.b_bool ); 
    11041104 
    1105     p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, 
    1106                                                  FIND_PARENT ); 
    1107     if( p_playlist ) 
    1108     { 
    1109         /* Modify playlist as well because the vout might have to be restarted */ 
    1110         var_Create( p_playlist, "video-on-top", VLC_VAR_BOOL ); 
    1111         var_Set( p_playlist, "video-on-top", newval ); 
    1112  
    1113         vlc_object_release( p_playlist ); 
    1114     } 
     1105    /* Modify playlist as well because the vout might have to be restarted */ 
     1106    var_Create( p_playlist, "video-on-top", VLC_VAR_BOOL ); 
     1107    var_Set( p_playlist, "video-on-top", newval ); 
     1108 
     1109    pl_Release( p_this ); 
    11151110    return VLC_SUCCESS; 
    11161111} 
     
    11201115{ 
    11211116    vout_thread_t *p_vout = (vout_thread_t *)p_this; 
    1122     playlist_t *p_playlist; 
    11231117    vlc_value_t val; 
     1118    playlist_t *p_playlist = pl_Yield( p_this ); 
    11241119 
    11251120    p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; 
    11261121 
    1127     p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, 
    1128                                                  FIND_PARENT ); 
    1129     if( p_playlist ) 
    1130     { 
    1131         /* Modify playlist as well because the vout might have to be restarted */ 
    1132         var_Create( p_playlist, "fullscreen", VLC_VAR_BOOL ); 
    1133         var_Set( p_playlist, "fullscreen", newval ); 
    1134  
    1135         vlc_object_release( p_playlist ); 
    1136     } 
     1122    /* Modify playlist as well because the vout might have to be restarted */ 
     1123    var_Create( p_playlist, "fullscreen", VLC_VAR_BOOL ); 
     1124    var_Set( p_playlist, "fullscreen", newval ); 
     1125    pl_Release( p_playlist ); 
    11371126 
    11381127    /* Disable "always on top" in fullscreen mode */