1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-28 23:09:59 +02:00

* Fixed autodelete

* Autodelete items played by the SDP demuxer
* Added playlist_CopyParents facility, for modules that use ItemToNode
This commit is contained in:
Clément Stenac 2004-11-07 10:43:52 +00:00
parent 001dfc8b9c
commit 211bbb8738
6 changed files with 45 additions and 50 deletions

2
TODO
View File

@ -119,7 +119,6 @@ Todo:<br />
- *** Improve random mode and fix loop<br />
- * "Name finder"<br />
- * "Protocol rollover" node<br />
- *** Fix autodeletion<br />
- *** Item moving/copying facilities<br />
- *** Live directory representation<br />
- Helper modules<br />
@ -632,6 +631,5 @@ Subtitle Files( .idx, .sub, .utf, .srt)<br />
Status: Todo
# Do not remove me
Task

View File

@ -216,6 +216,7 @@ VLC_EXPORT( int, playlist_Clear, ( playlist_t * ) );
VLC_EXPORT( playlist_item_t* , __playlist_ItemNew, ( vlc_object_t *,const char *,const char * ) );
VLC_EXPORT( void, playlist_ItemDelete, ( playlist_item_t * ) );
VLC_EXPORT( void, playlist_ItemAddParent, ( playlist_item_t *, int,playlist_item_t *) );
VLC_EXPORT( void, playlist_CopyParents, ( playlist_item_t *,playlist_item_t *) );
/* Item informations accessors */
VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, char * ) );
VLC_EXPORT( int, playlist_ItemSetDuration, (playlist_item_t *, mtime_t ) );

View File

@ -321,7 +321,6 @@ static int ReadDir( playlist_t *p_playlist,
DIR * p_current_dir;
struct dirent * p_dir_content;
playlist_item_t *p_node;
int i;
/* Change the item to a node */
if( p_parent->i_children == -1)
@ -381,15 +380,10 @@ static int ReadDir( playlist_t *p_playlist,
p_parent->pp_parents[0]->i_view,
psz_uri, p_parent );
playlist_CopyParents( p_parent, p_node );
p_node->input.i_type = ITEM_TYPE_DIRECTORY;
/* We need to declare the parents of the node as the
* same of the parent's ones */
for( i= 1 ; i< p_parent->i_parents; i ++ )
{
playlist_ItemAddParent( p_node,
p_parent->pp_parents[i]->i_view,
p_parent );
}
if( ReadDir( p_playlist, psz_uri , MODE_EXPAND,
pi_position, p_node ) != VLC_SUCCESS )
{
@ -401,20 +395,12 @@ static int ReadDir( playlist_t *p_playlist,
{
playlist_item_t *p_item = playlist_ItemNew( p_playlist,
psz_uri, p_dir_content->d_name );
fprintf(stderr,"STARTTTTt\n");
playlist_NodeAddItem( p_playlist,p_item,
p_parent->pp_parents[0]->i_view,
p_parent,
PLAYLIST_APPEND, PLAYLIST_END );
fprintf(stderr,"DONE\n");
/* We need to declare the parents of the node as the
* same of the parent's ones */
for( i= 1 ; i< p_parent->i_parents; i ++ )
{
playlist_ItemAddParent( p_item,
p_parent->pp_parents[i]->i_view,
p_parent );
}
playlist_CopyParents( p_parent, p_item );
}
}
free( psz_uri );

View File

@ -498,6 +498,8 @@ static int Demux( demux_t *p_demux )
p_playlist = (playlist_t *)vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
p_playlist->status.p_item->i_flags |= PLAYLIST_DEL_FLAG;
playlist_Add( p_playlist, p_sdp->psz_uri, p_sdp->psz_sessionname,
PLAYLIST_APPEND, PLAYLIST_END );

View File

@ -190,6 +190,21 @@ void playlist_ItemAddParent( playlist_item_t *p_item, int i_view,
}
}
/**
* Copy all parents from parent to child
*/
void playlist_CopyParents( playlist_item_t *p_parent,
playlist_item_t *p_child )
{
int i=0;
for( i= 0 ; i< p_parent->i_parents; i ++ )
{
playlist_ItemAddParent( p_child,
p_parent->pp_parents[i]->i_view,
p_parent );
}
}
/**********************************************************************
* playlist_item_t structure accessors

View File

@ -395,7 +395,7 @@ static void RunThread ( playlist_t *p_playlist )
mtime_t i_vout_destroyed_date = 0;
mtime_t i_sout_destroyed_date = 0;
playlist_item_t *p_autodelete_item = 0;
playlist_item_t *p_autodelete_item = NULL;
/* Tell above that we're ready */
vlc_thread_ready( p_playlist );
@ -452,13 +452,6 @@ static void RunThread ( playlist_t *p_playlist )
i_vout_destroyed_date = 0;
i_sout_destroyed_date = 0;
/* Check for autodeletion */
if( p_autodelete_item )
{
playlist_ItemDelete( p_autodelete_item );
p_autodelete_item = 0;
}
continue;
}
/* This input is dying, let him do */
@ -472,32 +465,15 @@ static void RunThread ( playlist_t *p_playlist )
{
/* TODO FIXME XXX TODO FIXME XXX */
/* Check for autodeletion */
input_StopThread( p_playlist->p_input );
if( p_playlist->status.p_item->i_flags & PLAYLIST_DEL_FLAG )
{
/* This ain't pretty but hey it works */
p_autodelete_item = p_playlist->status.p_item;
p_playlist->status.p_item =
playlist_ItemNew( p_playlist,
p_autodelete_item->input.psz_uri, 0);
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Delete( p_playlist,
p_playlist->status.p_item->input.i_id );
p_playlist->request.i_skip = 1;
p_playlist->status.i_status = PLAYLIST_RUNNING;
vlc_mutex_lock( &p_playlist->object_lock );
}
else
{
/* Select the next playlist item */
input_StopThread( p_playlist->p_input );
vlc_mutex_unlock( &p_playlist->object_lock );
continue;
}
input_StopThread( p_playlist->p_input );
/* Select the next playlist item */
vlc_mutex_unlock( &p_playlist->object_lock );
continue;
}
else if( p_playlist->p_input->i_state != INIT_S )
{
@ -517,15 +493,32 @@ static void RunThread ( playlist_t *p_playlist )
* Get the next item to play */
p_item = NextItem( p_playlist );
/* We must stop */
if( p_item == NULL )
{
if( p_autodelete_item )
{
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Delete( p_playlist,
p_autodelete_item->input.i_id );
vlc_mutex_lock( &p_playlist->object_lock );
p_autodelete_item = NULL;
}
p_playlist->status.i_status = PLAYLIST_STOPPED;
vlc_mutex_unlock( &p_playlist->object_lock );
continue;
}
PlayItem( p_playlist, p_item );
if( p_autodelete_item )
{
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Delete( p_playlist, p_autodelete_item->input.i_id );
vlc_mutex_lock( &p_playlist->object_lock );
p_autodelete_item = NULL;
}
}
else if( p_playlist->status.i_status == PLAYLIST_STOPPED )
{