📄 playlist.c
字号:
/***************************************************************************** * playlist.c : Playlist testsuite ***************************************************************************** * Copyright (C) 2004 the VideoLAN team * $Id: playlist.c 14118 2006-02-01 18:06:48Z courmisch $ * * Authors : Clément Stenac <zorglub@videolan.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//* To run these tests, run vlc with * --playlist-test --quiet --no-plugins-cache -I dummy *//* greek tree used for tests, borrowed from the SubVersion project * A iota _______________________//|\ / ______________/ | \_____________ mu / | \ / | \ B C D _____/|\_____ _____________/|\ / | \ / | \ / | \ / / \___ lambda | F / / \ E gamma / \ / \ / | / \ ________/ | alpha beta / H / _______/|\______ / / | \ G / | \ ________/|\_______ chi psi omega / | \ / | \ / | \ pi rho tau */ /***************************************************************************** * Preamble *****************************************************************************/#include <vlc/vlc.h>#include <vlc_input.h>#include <vlc_playlist.h>#include <stdlib.h>/***************************************************************************** * Local prototypes. *****************************************************************************/int PlaylistTest ( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * );static int Callback( vlc_object_t *, char *, vlc_value_t, vlc_value_t,void*);static void Assert( intf_sys_t *p_sys,const char* psz_text, int condition );static void StressTest (vlc_object_t *);#define MAX_ITEMS 100#define CREATE_GT 1000struct intf_sys_t{ char *ppsz_names[MAX_ITEMS]; playlist_t *p_playlist; int i_names; int i_current; vlc_bool_t b_error;};/***************************************************************************** * Module descriptor. *****************************************************************************/vlc_module_begin(); set_description( _("Playlist stress tests") ); add_bool( "playlist-test" , VLC_FALSE , PlaylistTest , "" , "" , VLC_TRUE );vlc_module_end();/***************************************************************************** * PlaylistTest: callback function, spawns the tester thread *****************************************************************************/int PlaylistTest( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ if( newval.b_bool == VLC_FALSE ) return VLC_SUCCESS; if( vlc_thread_create( p_this, "playlist tester", StressTest, VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) { msg_Err( p_this, "unable to spawn playlist test thread" ); return VLC_EGENERIC; } return VLC_SUCCESS;}/***************************************************************************** * Tester thread *****************************************************************************/static void StressTest( vlc_object_t *p_this ){ playlist_t *p_playlist = NULL; playlist_view_t *p_view; int i; mtime_t i_start; playlist_item_t *p_item,*p_a,*p_b,*p_c,*p_d,*p_e,*p_f,*p_g,*p_h, *p_gamma; intf_sys_t *p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) ); p_sys->b_error = VLC_FALSE; fprintf( stderr, "beginning playlist test\n" ); while( p_playlist == NULL ) { msleep( INTF_IDLE_SLEEP ); p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); } fprintf( stderr, "Attached to playlist\n"); p_sys->p_playlist = p_playlist; /* let time for vlc initialization */ sleep( 3 ); var_AddCallback( p_playlist, "playlist-current", Callback, p_sys ); /* Test 1 : Create a greek tree */ fprintf(stderr,"1/ Creating greek tree pattern (except H)\n"); p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY ); i_start = mdate(); playlist_Stop( p_playlist ); Assert( p_sys, "Checking playlist status STOPPED ...", p_playlist->status.i_status == PLAYLIST_STOPPED ); p_a = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "A", p_view->p_root ); p_item = playlist_ItemNew(p_playlist, "mu","mu" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_a, PLAYLIST_APPEND, PLAYLIST_END ); p_b = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "B", p_a ); p_c = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "C", p_a ); p_d = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "D", p_a ); p_item = playlist_ItemNew(p_playlist, "lambda","lambda" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_b, PLAYLIST_APPEND, PLAYLIST_END ); p_e = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "E", p_b ); p_f = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "F", p_b ); p_gamma = p_item = playlist_ItemNew(p_playlist, "gamma","gamma" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_d, PLAYLIST_APPEND, PLAYLIST_END ); p_g = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "G", p_d ); p_item = playlist_ItemNew(p_playlist, "beta","beta" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_e, PLAYLIST_INSERT, 0 ); p_item = playlist_ItemNew(p_playlist, "alpha","alpha" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_e, PLAYLIST_INSERT, 0 ); p_item = playlist_ItemNew(p_playlist, "pi","pi" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_g, PLAYLIST_APPEND, PLAYLIST_END ); p_item = playlist_ItemNew(p_playlist, "tau","tau" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_g, PLAYLIST_APPEND, PLAYLIST_END ); p_item = playlist_ItemNew(p_playlist, "rho","rho" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_g, PLAYLIST_INSERT, 1 ); /* Create H as an item, we'll expand it later */ p_item = playlist_ItemNew(p_playlist, "H","H" ); playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY, p_d, PLAYLIST_INSERT, 1 ); fprintf( stderr, "Created in "I64Fi " us\n", mdate() - i_start ); fprintf(stderr,"Dumping category view\n" ); playlist_ViewDump( p_playlist, p_view ); Assert( p_sys, "Checking playlist status STOPPED ...", p_playlist->status.i_status == PLAYLIST_STOPPED );// Assert( p_sys, "Checking 0 items in VIEW_SIMPLE ...", // playlist_ViewItemsCount( p_playlist, VIEW_SIMPLE ) == 0 );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -