[vlc-commits] playlist: don't play directories that can loop into themselves
Thomas Guillem
git at videolan.org
Wed May 20 16:10:26 CEST 2015
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon May 18 16:01:03 2015 +0200| [e4b58df6216824a08c3eddfcbe91eda39f6a5a51] | committer: Thomas Guillem
playlist: don't play directories that can loop into themselves
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e4b58df6216824a08c3eddfcbe91eda39f6a5a51
---
include/vlc_input_item.h | 1 +
modules/demux/playlist/directory.c | 6 +++++-
src/input/item.c | 1 +
src/playlist/item.c | 16 ++++++++++++++++
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 60dce6e..f86c405 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -122,6 +122,7 @@ struct input_item_node_t
input_item_node_t **pp_children;
input_item_node_t *p_parent;
input_item_compar_cb compar_cb;
+ bool b_can_loop;
};
VLC_API void input_item_CopyOptions( input_item_t *p_parent, input_item_t *p_child );
diff --git a/modules/demux/playlist/directory.c b/modules/demux/playlist/directory.c
index 51d3927..5c835bb 100644
--- a/modules/demux/playlist/directory.c
+++ b/modules/demux/playlist/directory.c
@@ -36,6 +36,7 @@
struct demux_sys_t
{
bool b_dir_sorted;
+ bool b_dir_can_loop;
};
/*****************************************************************************
@@ -50,14 +51,16 @@ int Import_Dir ( vlc_object_t *p_this)
bool b_is_dir = false;
bool b_dir_sorted = false;
+ bool b_dir_can_loop = false;
int i_err = stream_Control( p_demux->s, STREAM_IS_DIRECTORY, &b_is_dir,
- &b_dir_sorted, NULL );
+ &b_dir_sorted, &b_dir_can_loop );
if ( !( i_err == VLC_SUCCESS && b_is_dir ) )
return VLC_EGENERIC;
STANDARD_DEMUX_INIT_MSG( "reading directory content" );
p_demux->p_sys->b_dir_sorted = b_dir_sorted;
+ p_demux->p_sys->b_dir_can_loop = b_dir_can_loop;
return VLC_SUCCESS;
}
@@ -153,6 +156,7 @@ static int Demux( demux_t *p_demux )
p_input = GetCurrentItem( p_demux );
p_node = input_item_node_Create( p_input );
+ p_node->b_can_loop = p_demux->p_sys->b_dir_can_loop;
input_item_Release(p_input);
b_show_hiddenfiles = var_InheritBool( p_demux, "show-hiddenfiles" );
diff --git a/src/input/item.c b/src/input/item.c
index 10e7216..2dd8ca0 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1102,6 +1102,7 @@ input_item_node_t *input_item_node_Create( input_item_t *p_input )
p_node->p_parent = NULL;
p_node->i_children = 0;
p_node->pp_children = NULL;
+ p_node->b_can_loop = false;
return p_node;
}
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 5ce59f3..8d54e86 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -150,6 +150,22 @@ static void input_item_add_subitem_tree ( const vlc_event_t * p_event,
}
else
{
+ /* Don't Play a directory if it can loop into a parent */
+ if( p_new_root->b_can_loop )
+ {
+ /* Play the first regular file */
+ for( ; pos < last_pos; pos++ )
+ {
+ if( p_item->pp_children[pos]->p_input->i_type != ITEM_TYPE_DIRECTORY )
+ break;
+ }
+ if( last_pos == pos )
+ {
+ PL_UNLOCK;
+ playlist_Stop( p_playlist );
+ return;
+ }
+ }
p_play_item = p_item->pp_children[pos];
/* NOTE: this is a work around the general bug:
if node-to-be-played contains sub-nodes, then second instead
More information about the vlc-commits
mailing list