Skip to content

Commit

Permalink
playlist: don't play directories that can loop into themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
tguillem committed May 20, 2015
1 parent 8990da1 commit e4b58df
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/vlc_input_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 5 additions & 1 deletion modules/demux/playlist/directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
struct demux_sys_t
{
bool b_dir_sorted;
bool b_dir_can_loop;
};

/*****************************************************************************
Expand All @@ -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;
}
Expand Down Expand Up @@ -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" );
Expand Down
1 change: 1 addition & 0 deletions src/input/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 16 additions & 0 deletions src/playlist/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4b58df

Please sign in to comment.