Commit e4b58df6 authored by Thomas Guillem's avatar Thomas Guillem

playlist: don't play directories that can loop into themselves

parent 8990da12
......@@ -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 );
......
......@@ -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" );
......
......@@ -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;
}
......
......@@ -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
......
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