Changeset b86c36e69a31546e6215593dac7ebd4edea170e5

Show
Ignore:
Timestamp:
18/08/07 05:48:49 (1 year ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1187408929 +0000
git-parent:

[3d041f1336bfaffcadd5fb44d1647c7338d6c369]

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

modules/services_discovery/podcast.c: Use the new API.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/services_discovery/podcast.c

    r600e2cd rb86c36e  
    7979{ 
    8080    /* playlist node */ 
    81     playlist_item_t *p_node_cat; 
    82     playlist_item_t *p_node_one; 
    8381    input_thread_t **pp_input; 
    8482 
     
    102100    services_discovery_sys_t *p_sys  = malloc( 
    103101                                    sizeof( services_discovery_sys_t ) ); 
    104  
    105     vlc_value_t         val; 
    106     playlist_t          *p_playlist; 
    107     playlist_item_t     *p_item; 
     102     
     103    p_sys->i_urls = 0; 
     104    p_sys->ppsz_urls = NULL; 
     105    p_sys->pp_input = NULL; 
     106     
     107    p_sd->pf_run = Run; 
     108    p_sd->p_sys  = p_sys; 
     109 
     110    /* Give us a name */ 
     111    services_discovery_SetLocalizedName( p_sd, _("Podcasts") ); 
     112 
     113    return VLC_SUCCESS; 
     114
     115 
     116/***************************************************************************** 
     117 * Close: 
     118 *****************************************************************************/ 
     119static void Close( vlc_object_t *p_this ) 
     120
     121    services_discovery_t *p_sd = ( services_discovery_t* )p_this; 
     122    services_discovery_sys_t *p_sys  = p_sd->p_sys; 
     123    int i; 
     124    for( i = 0; i < p_sys->i_urls; i++ ) 
     125    { 
     126        if( p_sd->p_sys->pp_input[i] ) 
     127        { 
     128            input_StopThread( p_sd->p_sys->pp_input[i] ); 
     129            input_DestroyThread( p_sd->p_sys->pp_input[i] ); 
     130            p_sd->p_sys->pp_input[i] = NULL; 
     131        } 
     132    } 
     133    free( p_sd->p_sys->pp_input ); 
     134    for( i = 0; i < p_sys->i_urls; i++ ) free( p_sys->ppsz_urls[i] ); 
     135    free( p_sys->ppsz_urls ); 
     136    free( p_sys ); 
     137
     138 
     139/***************************************************************************** 
     140 * Run: main thread 
     141 *****************************************************************************/ 
     142static void Run( services_discovery_t *p_sd ) 
     143
     144    services_discovery_sys_t *p_sys  = p_sd->p_sys; 
    108145 
    109146    int i, j; 
     
    137174    free( psz_buf ); 
    138175 
    139     p_sd->pf_run = Run; 
    140     p_sd->p_sys  = p_sys; 
    141  
    142     /* Create our playlist node */ 
    143     p_playlist = (playlist_t *)vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST, 
    144                                                 FIND_ANYWHERE ); 
    145     if( !p_playlist ) 
    146     { 
    147         msg_Warn( p_sd, "unable to find playlist, cancelling"); 
    148         return VLC_EGENERIC; 
    149     } 
    150  
    151     p_sys->p_node_cat = playlist_NodeCreate( p_playlist, _("Podcast"), 
    152                                          p_playlist->p_root_category, 0 ); 
    153     p_sys->p_node_one = playlist_NodeCreate( p_playlist, _("Podcast"), 
    154                                          p_playlist->p_root_onelevel, 0 ); 
    155     p_sys->p_node_one->p_input->i_id = p_sys->p_node_cat->p_input->i_id; 
    156  
    157     p_sys->p_node_one->i_flags |= PLAYLIST_RO_FLAG; 
    158     p_sys->p_node_cat->i_flags |= PLAYLIST_RO_FLAG; 
    159     p_sys->p_node_one->i_flags |= PLAYLIST_SKIP_FLAG; 
    160     p_sys->p_node_cat->i_flags |= PLAYLIST_SKIP_FLAG; 
    161176    p_sys->pp_input = malloc( p_sys->i_urls * sizeof( input_thread_t * ) ); 
    162177    for( i = 0; i < p_sys->i_urls; i++ ) 
     
    164179        input_item_t *p_input; 
    165180        asprintf( &psz_buf, "%s", p_sys->ppsz_urls[i] ); 
    166         p_input = input_ItemNewExt( p_playlist, psz_buf, 
     181        p_input = input_ItemNewExt( p_sd, psz_buf, 
    167182                                    p_sys->ppsz_urls[i], 0, NULL, -1 ); 
    168183        input_ItemAddOption( p_input, "demux=podcast" ); 
    169         p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_cat, 
    170                                         PLAYLIST_APPEND, PLAYLIST_END, 
    171                                         VLC_FALSE ); 
    172         p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_one, 
    173                                         PLAYLIST_APPEND, PLAYLIST_END, 
    174                                         VLC_FALSE ); 
    175         free( psz_buf ); 
    176         p_sys->pp_input[i] = input_CreateThread( p_playlist, p_input ); 
    177     } 
    178  
    179     val.b_bool = VLC_TRUE; 
    180     var_Set( p_playlist, "intf-change", val ); 
    181  
    182     vlc_object_release( p_playlist ); 
    183  
    184     return VLC_SUCCESS; 
    185 
    186  
    187 /***************************************************************************** 
    188  * Close: 
    189  *****************************************************************************/ 
    190 static void Close( vlc_object_t *p_this ) 
    191 
    192     services_discovery_t *p_sd = ( services_discovery_t* )p_this; 
    193     services_discovery_sys_t *p_sys  = p_sd->p_sys; 
    194     playlist_t *p_playlist =  (playlist_t *) vlc_object_find( p_sd, 
    195                                  VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
    196     int i; 
    197     for( i = 0; i < p_sys->i_urls; i++ ) 
    198     { 
    199         if( p_sd->p_sys->pp_input[i] ) 
    200         { 
    201             input_StopThread( p_sd->p_sys->pp_input[i] ); 
    202             input_DestroyThread( p_sd->p_sys->pp_input[i] ); 
    203             p_sd->p_sys->pp_input[i] = NULL; 
    204         } 
    205     } 
    206     free( p_sd->p_sys->pp_input ); 
    207     if( p_playlist ) 
    208     { 
    209         playlist_NodeDelete( p_playlist, p_sys->p_node_cat, VLC_TRUE, VLC_TRUE ); 
    210         playlist_NodeDelete( p_playlist, p_sys->p_node_one, VLC_TRUE, VLC_TRUE ); 
    211         vlc_object_release( p_playlist ); 
    212     } 
    213     for( i = 0; i < p_sys->i_urls; i++ ) free( p_sys->ppsz_urls[i] ); 
    214     free( p_sys->ppsz_urls ); 
    215     free( p_sys ); 
    216 
    217  
    218 /***************************************************************************** 
    219  * Run: main thread 
    220  *****************************************************************************/ 
    221 static void Run( services_discovery_t *p_sd ) 
    222 
     184        services_discovery_AddItem( p_sd, p_input, NULL /* no cat */ ); 
     185        p_sys->pp_input[i] = input_CreateThread( p_sd, p_input ); 
     186    } 
     187 
    223188    while( !p_sd->b_die ) 
    224189    {