Changeset 25368dcd565835166b736d19615bb66324696b0b

Show
Ignore:
Timestamp:
14/12/05 19:10:27 (3 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1134583827 +0000
git-parent:

[eff1f159b6044e12f46aa11fdde69957e811c3d2]

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

Use input_Read in shoutcast and display a progress dialog

Files:

Legend:

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

    rd93b664 r25368dc  
    2929#include <vlc/vlc.h> 
    3030#include <vlc/intf.h> 
     31#include <vlc_interaction.h> 
    3132 
    3233#include <vlc/input.h> 
     
    8687    /* playlist node */ 
    8788    playlist_item_t *p_node; 
    88     input_thread_t *p_input; 
    89  
     89    playlist_item_t *p_item; 
     90    int i_limit; 
     91    vlc_bool_t b_dialog; 
    9092}; 
    9193 
     
    111113    playlist_item_t     *p_item; 
    112114 
    113     int i_limit; 
    114115    char *psz_shoutcast_url; 
    115116    char *psz_shoutcast_title; 
     
    127128    } 
    128129 
    129     i_limit = config_GetInt( p_this->p_libvlc, "shoutcast-limit" ); 
     130    p_sys->i_limit = config_GetInt( p_this->p_libvlc, "shoutcast-limit" ); 
    130131    #define SHOUTCAST_BASE_URL "http/shout-b4s://www.shoutcast.com/sbin/xmllister.phtml?service=vlc&no_compress=1&limit=" 
    131132    psz_shoutcast_url = (char *)malloc( strlen( SHOUTCAST_BASE_URL ) + 20 ); 
    132133    psz_shoutcast_title = (char *)malloc( 6 + 20 ); 
    133134 
    134     sprintf( psz_shoutcast_url, SHOUTCAST_BASE_URL "%d", i_limit ); 
    135     sprintf( psz_shoutcast_title, "Top %d", i_limit ); 
     135    sprintf( psz_shoutcast_url, SHOUTCAST_BASE_URL "%d", p_sys->i_limit ); 
     136    sprintf( psz_shoutcast_title, "Top %d", p_sys->i_limit ); 
    136137 
    137138    p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY ); 
     
    150151     * parent's ones */ 
    151152    playlist_CopyParents( p_sys->p_node, p_item ); 
    152      
    153  
    154     p_sys->p_input = input_CreateThread( p_playlist, &p_item->input ); 
    155  
     153 
     154    p_sys->p_item = p_item; 
    156155    p_sys->p_node->i_flags |= PLAYLIST_RO_FLAG; 
    157156    val.b_bool = VLC_TRUE; 
     
    172171    playlist_t *p_playlist =  (playlist_t *) vlc_object_find( p_sd, 
    173172                                 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
    174     if( p_sd->p_sys->p_input ) 
    175     { 
    176         input_StopThread( p_sd->p_sys->p_input ); 
    177         input_DestroyThread( p_sd->p_sys->p_input ); 
    178         vlc_object_detach( p_sd->p_sys->p_input ); 
    179         vlc_object_destroy( p_sd->p_sys->p_input ); 
    180         p_sd->p_sys->p_input = NULL;         
    181     } 
    182173    if( p_playlist ) 
    183174    { 
     
    193184static void Run( services_discovery_t *p_sd ) 
    194185{ 
     186    services_discovery_sys_t *p_sys  = p_sd->p_sys; 
     187    int i_id = input_Read( p_sd, &p_sys->p_item->input, VLC_FALSE ); 
     188    int i_dialog_id; 
     189 
     190    i_dialog_id = intf_UserProgress( p_sd, "Shoutcast" , "Connecting...", 0.0 ); 
     191 
     192    p_sys->b_dialog = VLC_TRUE; 
    195193    while( !p_sd->b_die ) 
    196194    { 
    197         if( p_sd->p_sys->p_input && 
    198             ( p_sd->p_sys->p_input->b_eof || p_sd->p_sys->p_input->b_error ) ) 
     195        input_thread_t *p_input = (input_thread_t *)vlc_object_get( p_sd, 
     196                                                                    i_id ); 
     197 
     198        /* The Shoutcast server does not return a content-length so we 
     199         * can't know where we are. Use the number of inserted items 
     200         * as a hint */ 
     201        if( p_input != NULL ) 
    199202        { 
    200             input_StopThread( p_sd->p_sys->p_input ); 
    201             input_DestroyThread( p_sd->p_sys->p_input ); 
    202             vlc_object_detach( p_sd->p_sys->p_input ); 
    203             vlc_object_destroy( p_sd->p_sys->p_input ); 
    204             p_sd->p_sys->p_input = NULL; 
     203            int i_state = var_GetInteger( p_input, "state" ); 
     204            if( i_state == PLAYING_S ) 
     205            { 
     206                float f_pos = (float)(p_sys->p_item->i_children)* 100.0 / 
     207                              (float)(p_sys->i_limit); 
     208                intf_UserProgressUpdate( p_sd, i_dialog_id, "Downloading", 
     209                                         f_pos ); 
     210            } 
     211            vlc_object_release( p_input ); 
     212        } 
     213        else if( p_sys->b_dialog ) 
     214        { 
     215            p_sys->b_dialog  = VLC_FALSE; 
     216            intf_UserHide( p_sd, i_dialog_id ); 
    205217        } 
    206218        msleep( 100000 );