Changeset 28d49d986f842beb59162ad66b3af94a7e1831bd

Show
Ignore:
Timestamp:
09/15/06 18:18:08 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1158337088 +0000
git-parent:

[8923568d00bddb39e34f82ee8b62152389321b77]

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

Store playlist object in instance-specific object

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    recddc27 r28d49d9  
    55085508 
    55095509dnl New definitions with value matching 0.8.6 release 
    5510 module_symbol="0_8_6b
     5510module_symbol="0_8_6c
    55115511AC_DEFINE_UNQUOTED(MODULE_SUFFIX, "__${module_symbol}", [String suffix for module functions]) 
    55125512AC_DEFINE_UNQUOTED(MODULE_SYMBOL, $module_symbol, [Symbol suffix for module functions]) 
  • include/main.h

    r8923568 r28d49d9  
    8181 
    8282    /* Global properties */ 
    83     int                    i_argc;           /* command line arguments count */ 
    84     char **                ppsz_argv;              /* command line arguments */ 
    85     char *                 psz_homedir;           /* configuration directory */ 
    86     char *                 psz_userdir;             /* user's home directory */ 
    87     char *                 psz_configfile;        /* location of config file */ 
     83    int                    i_argc;           ///< command line arguments count 
     84    char **                ppsz_argv;        ///< command line arguments 
     85    char *                 psz_homedir;      ///< configuration directory 
     86    char *                 psz_userdir;      ///< user's home directory 
     87    char *                 psz_configfile;   ///< location of config file 
    8888 
    89     /* Fast memcpy plugin used */ 
    90     module_t *             p_memcpy_module; 
    91     void* ( *pf_memcpy ) ( void *, const void *, size_t ); 
    92     void* ( *pf_memset ) ( void *, int, size_t ); 
     89    playlist_t            *p_playlist;       ///< playlist object 
    9390 
    94     /* Statistics */ 
    95     vlc_bool_t             b_stats;       ///< Should we collect stats 
    96     /* Timers handling */ 
     91    module_t *             p_memcpy_module;  ///< Fast memcpy plugin used 
     92    void* ( *pf_memcpy ) ( void *, const void *, size_t ); ///< fast memcpy  
     93    void* ( *pf_memset ) ( void *, int, size_t );          ///< fast memset 
     94 
     95    vlc_bool_t             b_stats;       ///< Should we collect stats ? 
    9796    vlc_mutex_t            timer_lock;    ///< Lock to protect timers 
    9897    int                    i_timers;      ///< Number of timers 
    9998    counter_t            **pp_timers;     ///< Array of all timers 
    10099 
    101     /* Locks */ 
    102     vlc_mutex_t            config_lock;          /* lock for the config file */ 
     100    vlc_mutex_t            config_lock;    ///< Lock for the config file 
    103101#ifdef __APPLE__ 
    104     vlc_mutex_t            quicktime_lock;          /* QT is not thread safe on OSX */ 
     102    vlc_mutex_t            quicktime_lock; ///< QT is not thread safe on OSX 
    105103#endif 
    106104 
  • include/vlc_playlist.h

    r4e5e7e2 r28d49d9  
    202202/* Global thread */ 
    203203#define playlist_ThreadCreate(a) __playlist_ThreadCreate(VLC_OBJECT(a)) 
    204 playlist_t *__playlist_ThreadCreate   ( vlc_object_t * ); 
     204void        __playlist_ThreadCreate   ( vlc_object_t * ); 
    205205int           playlist_ThreadDestroy  ( playlist_t * ); 
    206206 
  • src/libvlc.c

    r8923568 r28d49d9  
    245245    } 
    246246    p_libvlc->thread_id = 0; 
    247  
    248     p_libvlc->psz_object_name = "root"; 
     247    p_libvlc->p_playlist = NULL; 
     248    p_libvlc->psz_object_name = "libvlc"; 
    249249 
    250250    /* Initialize mutexes */ 
     
    263263    return p_libvlc->i_object_id; 
    264264} 
     265 
     266#define LIBVLC_FUNC \ 
     267    libvlc_int_t * p_libvlc = vlc_current_object( i_object ); \ 
     268    if( !p_libvlc ) return VLC_ENOOBJ; 
     269#define LIBVLC_FUNC_END \ 
     270    if( i_object ) vlc_object_release( p_libvlc ); 
     271 
    265272 
    266273/***************************************************************************** 
     
    291298#endif 
    292299#endif 
    293     libvlc_int_t * p_libvlc = vlc_current_object( i_object ); 
    294  
    295     if( !p_libvlc ) 
    296     { 
    297         return VLC_ENOOBJ; 
    298     } 
    299  
    300     /* 
    301      * System specific initialization code 
    302      */ 
     300    LIBVLC_FUNC; 
     301 
     302    /* System specific initialization code */ 
    303303    system_Init( p_libvlc, &i_argc, ppsz_argv ); 
    304304 
     
    728728    memcpy( p_libvlc->p_hotkeys, p_hotkeys, sizeof(p_hotkeys) ); 
    729729 
    730     /* 
    731      * Initialize playlist and get commandline files 
    732      */ 
    733     p_playlist = playlist_ThreadCreate( p_libvlc ); 
    734     if( !p_playlist ) 
     730    /* Initialize playlist and get commandline files */ 
     731    playlist_ThreadCreate( p_libvlc ); 
     732    if( !p_libvlc->p_playlist ) 
    735733    { 
    736734        msg_Err( p_libvlc, "playlist initialization failed" ); 
     
    743741        return VLC_EGENERIC; 
    744742    } 
     743    p_playlist = p_libvlc->p_playlist; 
    745744 
    746745    psz_modules = config_GetPsz( p_playlist, "services-discovery" ); 
     
    865864    if ( val.psz_string != NULL ) free( val.psz_string ); 
    866865 
    867     if( i_object ) vlc_object_release( p_libvlc )
     866    LIBVLC_FUNC_END
    868867    return VLC_SUCCESS; 
    869868} 
     
    893892int VLC_Die( int i_object ) 
    894893{ 
    895     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    896  
    897     if( !p_libvlc ) 
    898     { 
    899         return VLC_ENOOBJ; 
    900     } 
    901  
     894    LIBVLC_FUNC; 
    902895    p_libvlc->b_die = VLC_TRUE; 
    903  
    904     if( i_object ) vlc_object_release( p_libvlc ); 
     896    LIBVLC_FUNC_END; 
    905897    return VLC_SUCCESS; 
    906898} 
     
    916908    aout_instance_t    * p_aout; 
    917909    announce_handler_t * p_announce; 
    918     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    919  
    920     /* Check that the handle is valid */ 
    921     if( !p_libvlc ) 
    922     { 
    923         return VLC_ENOOBJ; 
    924     } 
    925  
    926     /* 
    927      * Ask the interfaces to stop and destroy them 
    928      */ 
     910     
     911    LIBVLC_FUNC; 
     912 
     913    /* Ask the interfaces to stop and destroy them */ 
    929914    msg_Dbg( p_libvlc, "removing all interfaces" ); 
    930915    while( (p_intf = vlc_object_find( p_libvlc, VLC_OBJECT_INTF, FIND_CHILD )) ) 
     
    936921    } 
    937922 
    938     /* 
    939      * Free playlist 
    940      */ 
    941     msg_Dbg( p_libvlc, "removing playlist handler" ); 
    942     while( (p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, 
    943                                           FIND_CHILD )) ) 
    944     { 
    945         vlc_object_detach( p_playlist ); 
    946         vlc_object_release( p_playlist ); 
    947         playlist_ThreadDestroy( p_playlist ); 
    948     } 
    949  
    950     /* 
    951      * Free video outputs 
    952      */ 
     923    /* Free playlist */ 
     924    msg_Dbg( p_libvlc, "removing playlist" ); 
     925    playlist_ThreadDestroy( p_libvlc->p_playlist ); 
     926 
     927    /* Free video outputs */ 
    953928    msg_Dbg( p_libvlc, "removing all video outputs" ); 
    954929    while( (p_vout = vlc_object_find( p_libvlc, VLC_OBJECT_VOUT, FIND_CHILD )) ) 
     
    959934    } 
    960935 
    961     /* 
    962      * Free audio outputs 
    963      */ 
     936    /* Free audio outputs */ 
    964937    msg_Dbg( p_libvlc, "removing all audio outputs" ); 
    965938    while( (p_aout = vlc_object_find( p_libvlc, VLC_OBJECT_AOUT, FIND_CHILD )) ) 
     
    973946    stats_TimersClean( p_libvlc ); 
    974947 
    975     /* 
    976      * Free announce handler(s?) 
    977      */ 
     948    /* Free announce handler(s?) */ 
    978949    while( (p_announce = vlc_object_find( p_libvlc, VLC_OBJECT_ANNOUNCE, 
    979950                                                 FIND_CHILD ) ) ) 
     
    985956    } 
    986957 
    987     if( i_object ) vlc_object_release( p_libvlc ); 
    988     return VLC_SUCCESS; 
     958    LIBVLC_FUNC_END; 
    989959} 
    990960 
     
    997967int VLC_Destroy( int i_object ) 
    998968{ 
    999     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    1000  
    1001     if( !p_libvlc ) 
    1002     { 
    1003         return VLC_ENOOBJ; 
    1004     } 
    1005  
    1006     /* 
    1007      * Free allocated memory 
    1008      */ 
     969    LIBVLC_FUNC; 
     970     
     971    /* Free allocated memory */ 
    1009972    if( p_libvlc->p_memcpy_module ) 
    1010973    { 
     
    1013976    } 
    1014977 
    1015     /* 
    1016      * Free module bank ! 
    1017      */ 
     978    /* Free module bank !  */ 
    1018979    module_EndBank( p_libvlc ); 
    1019980 
    1020     if( p_libvlc->psz_homedir ) 
    1021     { 
    1022         free( p_libvlc->psz_homedir ); 
    1023         p_libvlc->psz_homedir = NULL; 
    1024     } 
    1025  
    1026     if( p_libvlc->psz_userdir ) 
    1027     { 
    1028         free( p_libvlc->psz_userdir ); 
    1029         p_libvlc->psz_userdir = NULL; 
    1030     } 
    1031  
    1032     if( p_libvlc->psz_configfile ) 
    1033     { 
    1034         free( p_libvlc->psz_configfile ); 
    1035         p_libvlc->psz_configfile = NULL; 
    1036     } 
    1037  
    1038     if( p_libvlc->p_hotkeys ) 
    1039     { 
    1040         free( p_libvlc->p_hotkeys ); 
    1041         p_libvlc->p_hotkeys = NULL; 
    1042     } 
    1043  
    1044     /* 
    1045      * System specific cleaning code 
    1046      */ 
     981    FREENULL( p_libvlc->psz_homedir ); 
     982    FREENULL( p_libvlc->psz_userdir ); 
     983    FREENULL( p_libvlc->psz_configfile ); 
     984    FREENULL( p_libvlc->p_hotkeys ); 
     985 
     986    /* System specific cleaning code */ 
    1047987    system_End( p_libvlc ); 
    1048988 
     
    10781018int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value ) 
    10791019{ 
    1080     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    10811020    int i_ret; 
    1082  
    1083     if( !p_libvlc ) 
    1084     { 
    1085         return VLC_ENOOBJ; 
    1086     } 
     1021    LIBVLC_FUNC; 
    10871022 
    10881023    /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then 
     
    11191054    i_ret = var_Set( p_libvlc, psz_var, value ); 
    11201055 
    1121     if( i_object ) vlc_object_release( p_libvlc )
     1056    LIBVLC_FUNC_END
    11221057    return i_ret; 
    11231058} 
     
    11281063int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value ) 
    11291064{ 
    1130     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    11311065    int i_ret; 
    1132  
    1133     if( !p_libvlc ) 
    1134     { 
    1135         return VLC_ENOOBJ; 
    1136     } 
    1137  
     1066    LIBVLC_FUNC; 
    11381067    i_ret = var_Get( p_libvlc , psz_var, p_value ); 
    1139  
    1140     if( i_object ) vlc_object_release( p_libvlc ); 
     1068    LIBVLC_FUNC_END; 
    11411069    return i_ret; 
    11421070} 
     
    11481076{ 
    11491077    int i_type; 
    1150     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    1151  
    1152     if( !p_libvlc ) 
    1153     { 
    1154         return VLC_ENOOBJ; 
    1155     } 
    1156  
     1078    LIBVLC_FUNC; 
    11571079    /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then 
    11581080     * we handle it as a configuration variable. Don't tell Gildas :) -- sam */ 
     
    11881110        i_type = VLC_VAR_TYPE & var_Type( p_libvlc , psz_var ); 
    11891111 
    1190     if( i_object ) vlc_object_release( p_libvlc )
     1112    LIBVLC_FUNC_END
    11911113 
    11921114    if( i_type > 0 ) 
     
    11981120} 
    11991121 
     1122#define LIBVLC_PLAYLIST_FUNC \ 
     1123    libvlc_int_t *p_libvlc = vlc_current_object( i_object );\ 
     1124    if( !p_libvlc || !p_libvlc->p_playlist ) return VLC_ENOOBJ; \ 
     1125    vlc_object_yield( p_libvlc->p_playlist ); 
     1126 
     1127#define LIBVLC_PLAYLIST_FUNC_END \ 
     1128    vlc_object_release( p_libvlc->p_playlist ); \ 
     1129    if( i_object ) vlc_object_release( p_libvlc ); 
     1130 
    12001131/***************************************************************************** 
    12011132 * VLC_AddTarget: adds a target for playing. 
    12021133 ***************************************************************************** 
    1203  * This function adds psz_target to the current playlist. If a playlist does 
    1204  * not exist, it will create one. 
    1205  *****************************************************************************/ 
     1134 * This function adds psz_target to the playlist 
     1135 *****************************************************************************/ 
     1136 
    12061137int VLC_AddTarget( int i_object, char const *psz_target, 
    12071138                   char const **ppsz_options, int i_options, 
     
    12091140{ 
    12101141    int i_err; 
    1211     playlist_t *p_playlist; 
    1212     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    1213  
    1214     if( !p_libvlc ) 
    1215     { 
    1216         return VLC_ENOOBJ; 
    1217     } 
    1218  
    1219     p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
    1220  
    1221     if( p_playlist == NULL ) 
    1222     { 
    1223         msg_Dbg( p_libvlc, "no playlist present, creating one" ); 
    1224         p_playlist = playlist_ThreadCreate( p_libvlc ); 
    1225  
    1226         if( p_playlist == NULL ) 
    1227         { 
    1228             if( i_object ) vlc_object_release( p_libvlc ); 
    1229             return VLC_EGENERIC; 
    1230         } 
    1231  
    1232         vlc_object_yield( p_playlist ); 
    1233     } 
    1234  
    1235     i_err = playlist_PlaylistAddExt( p_playlist, psz_target, psz_target, 
    1236                              i_mode, i_pos, -1, ppsz_options, i_options); 
    1237  
    1238     vlc_object_release( p_playlist ); 
    1239  
    1240     if( i_object ) vlc_object_release( p_libvlc ); 
     1142    LIBVLC_PLAYLIST_FUNC; 
     1143    i_err = playlist_PlaylistAddExt( p_libvlc->p_playlist, psz_target, 
     1144                                     psz_target,  i_mode, i_pos, -1, 
     1145                                     ppsz_options, i_options ); 
     1146    LIBVLC_PLAYLIST_FUNC_END; 
    12411147    return i_err; 
    12421148} 
     
    12471153int VLC_Play( int i_object ) 
    12481154{ 
    1249     playlist_t * p_playlist; 
    1250     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    1251  
    1252     /* Check that the handle is valid */ 
    1253     if( !p_libvlc ) 
    1254     { 
    1255         return VLC_ENOOBJ; 
    1256     } 
    1257  
    1258     p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD ); 
    1259  
    1260     if( !p_playlist ) 
    1261     { 
    1262         if( i_object ) vlc_object_release( p_libvlc ); 
    1263         return VLC_ENOOBJ; 
    1264     } 
    1265  
    1266     playlist_Play( p_playlist ); 
    1267     vlc_object_release( p_playlist ); 
    1268  
    1269     if( i_object ) vlc_object_release( p_libvlc ); 
     1155    LIBVLC_PLAYLIST_FUNC; 
     1156    playlist_Play( p_libvlc->p_playlist ); 
     1157    LIBVLC_PLAYLIST_FUNC_END; 
    12701158    return VLC_SUCCESS; 
    12711159} 
     
    12761164int VLC_Pause( int i_object ) 
    12771165{ 
    1278     playlist_t * p_playlist; 
    1279     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    1280  
    1281     /* Check that the handle is valid */ 
    1282     if( !p_libvlc ) 
    1283     { 
    1284         return VLC_ENOOBJ; 
    1285     } 
    1286  
    1287     p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD ); 
    1288  
    1289     if( !p_playlist ) 
    1290     { 
    1291         if( i_object ) vlc_object_release( p_libvlc ); 
    1292         return VLC_ENOOBJ; 
    1293     } 
    1294  
    1295     playlist_Pause( p_playlist ); 
    1296     vlc_object_release( p_playlist ); 
    1297  
    1298     if( i_object ) vlc_object_release( p_libvlc ); 
     1166    LIBVLC_PLAYLIST_FUNC; 
     1167    playlist_Pause( p_libvlc->p_playlist ); 
     1168    LIBVLC_PLAYLIST_FUNC_END; 
    12991169    return VLC_SUCCESS; 
    13001170} 
     
    13051175int VLC_Stop( int i_object ) 
    13061176{ 
    1307     playlist_t * p_playlist; 
    1308     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    1309  
    1310     /* Check that the handle is valid */ 
    1311     if( !p_libvlc ) 
    1312     { 
    1313         return VLC_ENOOBJ; 
    1314     } 
    1315  
    1316     p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD ); 
    1317  
    1318     if( !p_playlist ) 
    1319     { 
    1320         if( i_object ) vlc_object_release( p_libvlc ); 
    1321         return VLC_ENOOBJ; 
    1322     } 
    1323  
    1324     playlist_Stop( p_playlist ); 
    1325     vlc_object_release( p_playlist ); 
    1326  
    1327     if( i_object ) vlc_object_release( p_libvlc ); 
     1177    LIBVLC_PLAYLIST_FUNC; 
     1178    playlist_Stop( p_libvlc->p_playlist ); 
     1179    LIBVLC_PLAYLIST_FUNC_END; 
    13281180    return VLC_SUCCESS; 
    13291181} 
     
    13341186vlc_bool_t VLC_IsPlaying( int i_object ) 
    13351187{ 
    1336     playlist_t * p_playlist; 
    13371188    vlc_bool_t   b_playing; 
    13381189 
    1339     libvlc_int_t *p_libvlc = vlc_current_object( i_object ); 
    1340  
    1341     /* Check that the handle is valid */ 
    1342     if( !p_libvlc ) 
    1343     { 
    1344         return VLC_ENOOBJ; 
    1345     } 
    1346  
    1347     p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD ); 
    1348  
    1349     if( !p_playlist ) 
    1350     { 
    1351         if( i_object ) vlc_object_release( p_libvlc ); 
    1352         return VLC_ENOOBJ; 
    1353     } 
    1354  
    1355     if( p_playlist->p_input ) 
     1190    LIBVLC_PLAYLIST_FUNC; 
     1191    if( p_libvlc->p_playlist->p_input ) 
    13561192    { 
    13571193        vlc_value_t  val; 
    1358         var_Get( p_playlist->p_input, "state", &val ); 
     1194        var_Get( p_libvlc->p_playlist->p_input, "state", &val ); 
    13591195        b_playing = ( val.i_int == PLAYING_S ); 
    13601196    } 
    13611197    else 
    13621198    { 
    1363         b_playing = playlist_IsPlaying( p_playlist ); 
    1364     } 
    1365     vlc_object_release( p_playlist ); 
    1366  
    1367     if( i_object ) vlc_object_release( p_libvlc ); 
     1199        b_playing = playlist_IsPlaying( p_libvlc->p_playlist ); 
     1200    } 
     1201    LIBVLC_PLAYLIST_FUNC_END; 
    13681202    return b_playing; 
    13691203} 
  • src/playlist/engine.c

    rf485214 r28d49d9  
    5454        return NULL; 
    5555    } 
     56    p_parent->p_libvlc->p_playlist = p_playlist; 
    5657 
    5758    VariablesInit( p_playlist ); 
     
    171172    vlc_mutex_destroy( &p_playlist->gc_lock ); 
    172173    vlc_object_destroy( p_playlist->p_preparse ); 
     174    vlc_object_detach( p_playlist ); 
    173175    vlc_object_destroy( p_playlist ); 
    174176 
  • src/playlist/item.c

    r315069b r28d49d9  
    5757                                              input_item_t *p_input ) 
    5858{ 
    59     /** FIXME !!!!! don't find playlist each time */ 
    60     playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_obj, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
    6159    DECMALLOC_NULL( p_item, playlist_item_t ); 
     60    playlist_t *p_playlist = p_obj->p_libvlc->p_playlist; 
     61    vlc_object_yield( p_playlist ); 
    6262 
    6363    p_item->p_input = p_input; 
  • src/playlist/thread.c

    r928454f r28d49d9  
    5858 * \return an object with a started thread 
    5959 */ 
    60 playlist_t * __playlist_ThreadCreate( vlc_object_t *p_parent ) 
     60void __playlist_ThreadCreate( vlc_object_t *p_parent ) 
    6161{ 
    6262    playlist_t *p_playlist; 
    6363    p_playlist = CreatePlaylist( p_parent ); 
    6464 
    65     if( !p_playlist ) return NULL
     65    if( !p_playlist ) return
    6666 
    6767    // Stats 
     
    7979        msg_Err( p_playlist, "unable to create preparser" ); 
    8080        vlc_object_destroy( p_playlist ); 
    81         return NULL
     81        return
    8282    } 
    8383    p_playlist->p_preparse->i_waiting = 0; 
     
    9191        vlc_object_detach( p_playlist->p_preparse ); 
    9292        vlc_object_destroy( p_playlist->p_preparse ); 
    93         return NULL
     93        return
    9494    } 
    9595 
     
    100100        msg_Err( p_playlist, "cannot spawn playlist thread" ); 
    101101        vlc_object_destroy( p_playlist ); 
    102         return NULL
     102        return
    103103    } 
    104104 
     
    106106    vlc_object_attach( p_playlist, p_parent ); 
    107107 
    108     return p_playlist
     108    return
    109109} 
    110110