Commit 211bbb87 authored by Clément Stenac's avatar Clément Stenac

* Fixed autodelete

* Autodelete items played by the SDP demuxer
* Added playlist_CopyParents facility, for modules that use ItemToNode
parent 001dfc8b
...@@ -119,7 +119,6 @@ Todo:<br /> ...@@ -119,7 +119,6 @@ Todo:<br />
- *** Improve random mode and fix loop<br /> - *** Improve random mode and fix loop<br />
- * "Name finder"<br /> - * "Name finder"<br />
- * "Protocol rollover" node<br /> - * "Protocol rollover" node<br />
- *** Fix autodeletion<br />
- *** Item moving/copying facilities<br /> - *** Item moving/copying facilities<br />
- *** Live directory representation<br /> - *** Live directory representation<br />
- Helper modules<br /> - Helper modules<br />
...@@ -632,6 +631,5 @@ Subtitle Files( .idx, .sub, .utf, .srt)<br /> ...@@ -632,6 +631,5 @@ Subtitle Files( .idx, .sub, .utf, .srt)<br />
Status: Todo Status: Todo
# Do not remove me # Do not remove me
Task Task
...@@ -216,6 +216,7 @@ VLC_EXPORT( int, playlist_Clear, ( playlist_t * ) ); ...@@ -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( playlist_item_t* , __playlist_ItemNew, ( vlc_object_t *,const char *,const char * ) );
VLC_EXPORT( void, playlist_ItemDelete, ( playlist_item_t * ) ); VLC_EXPORT( void, playlist_ItemDelete, ( playlist_item_t * ) );
VLC_EXPORT( void, playlist_ItemAddParent, ( playlist_item_t *, int,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 */ /* Item informations accessors */
VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, char * ) ); VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, char * ) );
VLC_EXPORT( int, playlist_ItemSetDuration, (playlist_item_t *, mtime_t ) ); VLC_EXPORT( int, playlist_ItemSetDuration, (playlist_item_t *, mtime_t ) );
......
...@@ -321,7 +321,6 @@ static int ReadDir( playlist_t *p_playlist, ...@@ -321,7 +321,6 @@ static int ReadDir( playlist_t *p_playlist,
DIR * p_current_dir; DIR * p_current_dir;
struct dirent * p_dir_content; struct dirent * p_dir_content;
playlist_item_t *p_node; playlist_item_t *p_node;
int i;
/* Change the item to a node */ /* Change the item to a node */
if( p_parent->i_children == -1) if( p_parent->i_children == -1)
...@@ -381,15 +380,10 @@ static int ReadDir( playlist_t *p_playlist, ...@@ -381,15 +380,10 @@ static int ReadDir( playlist_t *p_playlist,
p_parent->pp_parents[0]->i_view, p_parent->pp_parents[0]->i_view,
psz_uri, p_parent ); psz_uri, p_parent );
playlist_CopyParents( p_parent, p_node );
p_node->input.i_type = ITEM_TYPE_DIRECTORY; 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, if( ReadDir( p_playlist, psz_uri , MODE_EXPAND,
pi_position, p_node ) != VLC_SUCCESS ) pi_position, p_node ) != VLC_SUCCESS )
{ {
...@@ -401,20 +395,12 @@ static int ReadDir( playlist_t *p_playlist, ...@@ -401,20 +395,12 @@ static int ReadDir( playlist_t *p_playlist,
{ {
playlist_item_t *p_item = playlist_ItemNew( p_playlist, playlist_item_t *p_item = playlist_ItemNew( p_playlist,
psz_uri, p_dir_content->d_name ); psz_uri, p_dir_content->d_name );
fprintf(stderr,"STARTTTTt\n");
playlist_NodeAddItem( p_playlist,p_item, playlist_NodeAddItem( p_playlist,p_item,
p_parent->pp_parents[0]->i_view, p_parent->pp_parents[0]->i_view,
p_parent, p_parent,
PLAYLIST_APPEND, PLAYLIST_END ); PLAYLIST_APPEND, PLAYLIST_END );
fprintf(stderr,"DONE\n");
/* We need to declare the parents of the node as the playlist_CopyParents( p_parent, p_item );
* 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 );
}
} }
} }
free( psz_uri ); free( psz_uri );
......
...@@ -498,6 +498,8 @@ static int Demux( demux_t *p_demux ) ...@@ -498,6 +498,8 @@ static int Demux( demux_t *p_demux )
p_playlist = (playlist_t *)vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST, p_playlist = (playlist_t *)vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); 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_Add( p_playlist, p_sdp->psz_uri, p_sdp->psz_sessionname,
PLAYLIST_APPEND, PLAYLIST_END ); PLAYLIST_APPEND, PLAYLIST_END );
......
...@@ -190,6 +190,21 @@ void playlist_ItemAddParent( playlist_item_t *p_item, int i_view, ...@@ -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 * playlist_item_t structure accessors
......
...@@ -395,7 +395,7 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -395,7 +395,7 @@ static void RunThread ( playlist_t *p_playlist )
mtime_t i_vout_destroyed_date = 0; mtime_t i_vout_destroyed_date = 0;
mtime_t i_sout_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 */ /* Tell above that we're ready */
vlc_thread_ready( p_playlist ); vlc_thread_ready( p_playlist );
...@@ -452,13 +452,6 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -452,13 +452,6 @@ static void RunThread ( playlist_t *p_playlist )
i_vout_destroyed_date = 0; i_vout_destroyed_date = 0;
i_sout_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; continue;
} }
/* This input is dying, let him do */ /* This input is dying, let him do */
...@@ -472,33 +465,16 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -472,33 +465,16 @@ static void RunThread ( playlist_t *p_playlist )
{ {
/* TODO FIXME XXX TODO FIXME XXX */ /* TODO FIXME XXX TODO FIXME XXX */
/* Check for autodeletion */ /* Check for autodeletion */
input_StopThread( p_playlist->p_input );
if( p_playlist->status.p_item->i_flags & PLAYLIST_DEL_FLAG ) 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_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 ); input_StopThread( p_playlist->p_input );
/* Select the next playlist item */
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
continue; continue;
} }
}
else if( p_playlist->p_input->i_state != INIT_S ) else if( p_playlist->p_input->i_state != INIT_S )
{ {
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
...@@ -517,15 +493,32 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -517,15 +493,32 @@ static void RunThread ( playlist_t *p_playlist )
* Get the next item to play */ * Get the next item to play */
p_item = NextItem( p_playlist ); p_item = NextItem( p_playlist );
/* We must stop */ /* We must stop */
if( p_item == NULL ) 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; p_playlist->status.i_status = PLAYLIST_STOPPED;
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
continue; continue;
} }
PlayItem( p_playlist, p_item ); 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 ) else if( p_playlist->status.i_status == PLAYLIST_STOPPED )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment