Changeset 222960cff9c3968b0c6b8c073bfa08182e3cc78a

Show
Ignore:
Timestamp:
11/10/07 03:02:50 (1 year ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1192064570 +0000
git-parent:

[393b8a063539c0230473e517e6ffe37fc290b810]

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

playlist/services_discovery.c: Isolate more the services_discovery code from the playlist code by having two separate header. Partly revert [22536].

Files:

Legend:

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

    rd3b42e4 r222960c  
    3636#include <vlc_input.h> 
    3737#include <vlc_events.h> 
     38#include <vlc_services_discovery.h> 
    3839#include <stdio.h> 
    3940#include <stdlib.h> 
     
    159160{ PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t; 
    160161 
    161  
    162 struct services_discovery_t 
    163 { 
    164     VLC_COMMON_MEMBERS 
    165     char *              psz_module; 
    166     module_t *          p_module; 
    167  
    168     char *              psz_localized_name; /* Accessed through Setters for non class function */ 
    169     vlc_event_manager_t event_manager;      /* Accessed through Setters for non class function */ 
    170  
    171     /* the playlist items for category and onelevel */ 
    172     playlist_item_t*    p_cat; 
    173     playlist_item_t*    p_one; 
    174  
    175     services_discovery_sys_t *p_sys; 
    176     void (*pf_run) ( services_discovery_t *); 
    177 }; 
    178  
    179162/** Structure containing information about the playlist */ 
    180163struct playlist_t 
     
    182165    VLC_COMMON_MEMBERS 
    183166 
    184     /* pp_sd & i_sd are for internal use ONLY. Understood ? it's PRIVATE ! */ 
    185     services_discovery_t **pp_sd; /**< Loaded service discovery modules */ 
    186     int                   i_sd;   /**< Number of service discovery modules */ 
     167    struct playlist_services_discovery_support_t { 
     168        /* the playlist items for category and onelevel */ 
     169        playlist_item_t*    p_cat; 
     170        playlist_item_t*    p_one; 
     171        services_discovery_t * p_sd; /**< Loaded service discovery modules */ 
     172    } ** pp_sds; 
     173    int                   i_sds;   /**< Number of service discovery modules */ 
    187174 
    188175    int                   i_enabled; /**< How many items are enabled ? */ 
     
    417404VLC_EXPORT( playlist_item_t *, playlist_GetPrevLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root, playlist_item_t *p_item, vlc_bool_t b_ena, vlc_bool_t b_unplayed ) ); 
    418405VLC_EXPORT( playlist_item_t *, playlist_GetLastLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root ) ); 
    419  
    420 /*********************************************************************** 
    421  * Service Discovery 
    422  ***********************************************************************/ 
    423  
    424 /* Get the services discovery modules names to use in Create(), in a null 
    425  * terminated string array. Array and string must be freed after use. */ 
    426 VLC_EXPORT( char **, services_discovery_GetServicesNames, ( vlc_object_t * p_super ) ); 
    427  
    428 /* Creation of a service_discovery object */ 
    429 VLC_EXPORT( services_discovery_t *, services_discovery_Create, ( vlc_object_t * p_super, const char * psz_service_name ) ); 
    430 VLC_EXPORT( void,                   services_discovery_Destroy, ( services_discovery_t * p_this ) ); 
    431 VLC_EXPORT( int,                    services_discovery_Start, ( services_discovery_t * p_this ) ); 
    432 VLC_EXPORT( void,                   services_discovery_Stop, ( services_discovery_t * p_this ) ); 
    433  
    434 /* Read info from discovery object */ 
    435 VLC_EXPORT( char *,                 services_discovery_GetLocalizedName, ( services_discovery_t * p_this ) ); 
    436  
    437 /* Receive event notification (prefered way to get new items) */ 
    438 VLC_EXPORT( vlc_event_manager_t *,  services_discovery_EventManager, ( services_discovery_t * p_this ) ); 
    439  
    440 /* Used by services_discovery to post update about their items */ 
    441 VLC_EXPORT( void,                   services_discovery_SetLocalizedName, ( services_discovery_t * p_this, const char * ) ); 
    442     /* About the psz_category, it is a legacy way to add info to the item, 
    443      * for more options, directly set the (meta) data on the input item */ 
    444 VLC_EXPORT( void,                   services_discovery_AddItem, ( services_discovery_t * p_this, input_item_t * p_item, const char * psz_category ) ); 
    445 VLC_EXPORT( void,                   services_discovery_RemoveItem, ( services_discovery_t * p_this, input_item_t * p_item ) ); 
    446406 
    447407/*********************************************************************** 
  • src/playlist/engine.c

    rd3b42e4 r222960c  
    6767    } 
    6868 
    69     TAB_INIT( p_playlist->i_sd, p_playlist->pp_sd ); 
     69    TAB_INIT( p_playlist->i_sds, p_playlist->pp_sds ); 
    7070 
    7171    p_parent->p_libvlc->p_playlist = p_playlist; 
     
    438438    } 
    439439 
    440     while( p_playlist->i_sd
     440    while( p_playlist->i_sds
    441441    { 
    442442        playlist_ServicesDiscoveryRemove( p_playlist, 
    443                                           p_playlist->pp_sd[0]->psz_module ); 
     443                                          p_playlist->pp_sds[0]->p_sd->psz_module ); 
    444444    } 
    445445 
  • src/playlist/services_discovery.c

    r393b8a0 r222960c  
    253253    for (;;) 
    254254    { 
     255        struct playlist_services_discovery_support_t * p_sds; 
    255256        playlist_item_t * p_cat; 
    256257        playlist_item_t * p_one; 
     
    294295            PL_UNLOCK; 
    295296        } 
    296         p_sd->p_cat = p_cat; 
    297         p_sd->p_one = p_one; 
    298297 
    299298        vlc_event_attach( services_discovery_EventManager( p_sd ), 
     
    319318        services_discovery_Start( p_sd ); 
    320319 
     320        /* Free in playlist_ServicesDiscoveryRemove */  
     321        p_sds = malloc( sizeof(struct playlist_services_discovery_support_t) ); 
     322        if( !p_sds ) 
     323        { 
     324            msg_Err( p_playlist, "No more memory" ); 
     325            return VLC_ENOMEM; 
     326        } 
     327        p_sds->p_sd = p_sd;  
     328        p_sds->p_one = p_one;  
     329        p_sds->p_cat = p_cat;  
     330 
    321331        PL_LOCK; 
    322         TAB_APPEND( p_playlist->i_sd, p_playlist->pp_sd, p_sd ); 
     332        TAB_APPEND( p_playlist->i_sds, p_playlist->pp_sds, p_sds ); 
    323333        PL_UNLOCK; 
    324334    } 
     
    330340                                       const char *psz_module ) 
    331341{ 
     342    struct playlist_services_discovery_support_t * p_sds = NULL; 
    332343    int i; 
    333     struct services_discovery_t *p_sd = NULL; 
    334344 
    335345    PL_LOCK; 
    336     for( i = 0 ; i< p_playlist->i_sd ; i ++ ) 
    337     { 
    338         if( !strcmp( psz_module, p_playlist->pp_sd[i]->psz_module ) ) 
    339         { 
    340             p_sd = p_playlist->pp_sd[i]; 
    341             REMOVE_ELEM( p_playlist->pp_sd, p_playlist->i_sd, i ); 
     346    for( i = 0 ; i< p_playlist->i_sds ; i ++ ) 
     347    { 
     348        if( !strcmp( psz_module, p_playlist->pp_sds[i]->p_sd->psz_module ) ) 
     349        { 
     350            p_sds = p_playlist->pp_sds[i]; 
     351            REMOVE_ELEM( p_playlist->pp_sds, p_playlist->i_sds, i ); 
    342352            break; 
    343353        } 
     
    345355    PL_UNLOCK; 
    346356 
    347     if( p_sd == NULL
     357    if( !p_sds || !p_sds->p_sd
    348358    { 
    349359        msg_Warn( p_playlist, "module %s is not loaded", psz_module ); 
     
    351361    } 
    352362 
    353     services_discovery_Stop( p_sd ); 
    354  
    355     vlc_event_detach( services_discovery_EventManager( p_sd ), 
     363    services_discovery_Stop( p_sds->p_sd ); 
     364 
     365    vlc_event_detach( services_discovery_EventManager( p_sds->p_sd ), 
    356366                        vlc_ServicesDiscoveryItemAdded, 
    357367                        playlist_sd_item_added, 
    358                         p_sd->p_one ); 
    359  
    360     vlc_event_detach( services_discovery_EventManager( p_sd ), 
     368                        p_sds->p_one ); 
     369 
     370    vlc_event_detach( services_discovery_EventManager( p_sds->p_sd ), 
    361371                        vlc_ServicesDiscoveryItemAdded, 
    362372                        playlist_sd_item_added, 
    363                         p_sd->p_cat ); 
    364  
    365     vlc_event_detach( services_discovery_EventManager( p_sd ), 
     373                        p_sds->p_cat ); 
     374 
     375    vlc_event_detach( services_discovery_EventManager( p_sds->p_sd ), 
    366376                        vlc_ServicesDiscoveryItemRemoved, 
    367377                        playlist_sd_item_removed, 
    368                         p_sd->p_one ); 
    369  
    370     vlc_event_detach( services_discovery_EventManager( p_sd ), 
     378                        p_sds->p_one ); 
     379 
     380    vlc_event_detach( services_discovery_EventManager( p_sds->p_sd ), 
    371381                        vlc_ServicesDiscoveryItemRemoved, 
    372382                        playlist_sd_item_removed, 
    373                         p_sd->p_cat ); 
     383                        p_sds->p_cat ); 
    374384 
    375385    /* Remove the sd playlist node if it exists */ 
    376386    PL_LOCK; 
    377     if( p_sd->p_cat != p_playlist->p_root_category && 
    378         p_sd->p_one != p_playlist->p_root_onelevel ) 
    379     { 
    380         playlist_NodeDelete( p_playlist, p_sd->p_cat, VLC_TRUE, VLC_FALSE ); 
    381         playlist_NodeDelete( p_playlist, p_sd->p_one, VLC_TRUE, VLC_FALSE ); 
     387    if( p_sds->p_cat != p_playlist->p_root_category && 
     388        p_sds->p_one != p_playlist->p_root_onelevel ) 
     389    { 
     390        playlist_NodeDelete( p_playlist, p_sds->p_cat, VLC_TRUE, VLC_FALSE ); 
     391        playlist_NodeDelete( p_playlist, p_sds->p_one, VLC_TRUE, VLC_FALSE ); 
    382392    } 
    383393    PL_UNLOCK; 
    384394 
    385     services_discovery_Destroy( p_sd ); 
     395    services_discovery_Destroy( p_sds->p_sd ); 
    386396 
    387397    return VLC_SUCCESS; 
     
    394404    PL_LOCK; 
    395405 
    396     for( i = 0 ; i< p_playlist->i_sd ; i ++ ) 
    397     { 
    398         if( !strcmp( psz_module, p_playlist->pp_sd[i]->psz_module ) ) 
     406    for( i = 0 ; i< p_playlist->i_sds ; i ++ ) 
     407    { 
     408        if( !strcmp( psz_module, p_playlist->pp_sds[i]->p_sd->psz_module ) ) 
    399409        { 
    400410            PL_UNLOCK;