#include <vlc_input.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
+#include <vlc_rand.h>
#include "stream_output/stream_output.h"
#include "playlist_internal.h"
/* release input resources */
if( p_sys->p_input_resource )
- input_resource_Delete( p_sys->p_input_resource );
+ {
+ input_resource_Terminate( p_sys->p_input_resource );
+ input_resource_Release( p_sys->p_input_resource );
+ }
p_sys->p_input_resource = NULL;
if( var_InheritBool( p_playlist, "media-library" ) )
PL_DEBUG("rebuild done - %i items, index %i", p_playlist->current.i_size,
p_playlist->i_current_index);
- if( var_GetBool( p_playlist, "random" ) )
+ if( var_GetBool( p_playlist, "random" ) && ( p_playlist->current.i_size > 0 ) )
{
/* Shuffle the array */
- srand( (unsigned int)mdate() );
- for( int j = p_playlist->current.i_size - 1; j > 0; j-- )
+ for( unsigned j = p_playlist->current.i_size - 1; j > 0; j-- )
{
- int i = rand() % (j+1); /* between 0 and j */
+ unsigned i = vlc_lrand48() % (j+1); /* between 0 and j */
playlist_item_t *p_tmp;
/* swap the two items */
p_tmp = ARRAY_VAL(p_playlist->current, i);
assert( p_sys->p_input == NULL );
+ if( !p_sys->p_input_resource )
+ p_sys->p_input_resource = input_resource_New( VLC_OBJECT( p_playlist ) );
input_thread_t *p_input_thread = input_Create( p_playlist, p_input, NULL, p_sys->p_input_resource );
if( p_input_thread )
{
}
}
- p_sys->p_input_resource = NULL;
-
char *psz_uri = input_item_GetURI( p_item->p_input );
if( psz_uri && ( !strncmp( psz_uri, "directory:", 10 ) ||
!strncmp( psz_uri, "vlc:", 4 ) ) )
{
PL_DEBUG( "dead input" );
- assert( p_sys->p_input_resource == NULL );
-
- p_sys->p_input_resource = input_DetachResource( p_input );
-
PL_UNLOCK;
/* We can unlock as we return VLC_EGENERIC (no event will be lost) */