#include "input_internal.h"
-#undef STREAM_DEBUG
+// #define STREAM_DEBUG 1
/* TODO:
* - tune the 2 methods (block/stream)
access_entry_t **list;
int i_list_index;
access_t *p_list_access;
-
- /* Preparse mode ? */
- bool b_quick;
};
/* Method 1: */
vlc_iconv_close( s->p_text->conv );
free( s->p_text );
}
+ free( s->psz_path );
vlc_object_release( s );
}
return NULL;
}
- if( !( p_res = stream_AccessNew( p_access, true ) ) )
+ if( !( p_res = stream_AccessNew( p_access, NULL ) ) )
{
access_Delete( p_access );
return NULL;
return p_res;
}
-stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
+stream_t *stream_AccessNew( access_t *p_access, char **ppsz_list )
{
stream_t *s = stream_CommonNew( VLC_OBJECT(p_access) );
stream_sys_t *p_sys;
- char *psz_list = NULL;
if( !s )
return NULL;
- s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
- if( !p_sys )
+ s->psz_path = strdup( p_access->psz_path );
+ s->p_sys = p_sys = malloc( sizeof( *p_sys ) );
+ if( !s->psz_path || !s->p_sys )
{
stream_CommonDelete( s );
return NULL;
p_sys->stat.i_seek_count = 0;
p_sys->stat.i_seek_time = 0;
- p_sys->i_list = 0;
- p_sys->list = 0;
+ TAB_INIT( p_sys->i_list, p_sys->list );
p_sys->i_list_index = 0;
- p_sys->p_list_access = 0;
-
- p_sys->b_quick = b_quick;
+ p_sys->p_list_access = NULL;
/* Get the additional list of inputs if any (for concatenation) */
- if( (psz_list = var_CreateGetString( s, "input-list" )) && *psz_list )
+ if( ppsz_list && ppsz_list[0] )
{
- access_entry_t *p_entry = malloc( sizeof(access_entry_t) );
- if( p_entry == NULL )
+ access_entry_t *p_entry = malloc( sizeof(*p_entry) );
+ if( !p_entry )
goto error;
- char *psz_name, *psz_parser = psz_name = psz_list;
- p_sys->p_list_access = p_access;
p_entry->i_size = p_access->info.i_size;
p_entry->psz_path = strdup( p_access->psz_path );
- if( p_entry->psz_path == NULL )
+ if( !p_entry->psz_path )
{
free( p_entry );
goto error;
}
+ p_sys->p_list_access = p_access;
TAB_APPEND( p_sys->i_list, p_sys->list, p_entry );
msg_Dbg( p_access, "adding file `%s', (%"PRId64" bytes)",
p_entry->psz_path, p_access->info.i_size );
- while( psz_name && *psz_name )
+ for( int i = 0; ppsz_list[i] != NULL; i++ )
{
- psz_parser = strchr( psz_name, ',' );
- if( psz_parser ) *psz_parser = 0;
+ char *psz_name = strdup( ppsz_list[i] );
- psz_name = strdup( psz_name );
- if( psz_name )
- {
- access_t *p_tmp = access_New( p_access, p_access->psz_access,
- "", psz_name );
+ if( !psz_name )
+ break;
- if( !p_tmp )
- {
- psz_name = psz_parser;
- if( psz_name ) psz_name++;
- continue;
- }
+ access_t *p_tmp = access_New( p_access,
+ p_access->psz_access, "", psz_name );
+ if( !p_tmp )
+ continue;
- msg_Dbg( p_access, "adding file `%s', (%"PRId64" bytes)",
- psz_name, p_tmp->info.i_size );
+ msg_Dbg( p_access, "adding file `%s', (%"PRId64" bytes)",
+ psz_name, p_tmp->info.i_size );
- p_entry = malloc( sizeof(access_entry_t) );
- if( p_entry == NULL )
- goto error;
+ p_entry = malloc( sizeof(*p_entry) );
+ if( p_entry )
+ {
p_entry->i_size = p_tmp->info.i_size;
p_entry->psz_path = psz_name;
TAB_APPEND( p_sys->i_list, p_sys->list, p_entry );
-
- access_Delete( p_tmp );
}
-
- psz_name = psz_parser;
- if( psz_name ) psz_name++;
+ access_Delete( p_tmp );
}
}
- FREENULL( psz_list );
/* Peek */
p_sys->i_peek = 0;
if( p_sys->stream.p_buffer == NULL )
goto error;
p_sys->stream.i_used = 0;
- access_Control( p_access, ACCESS_GET_MTU,
- &p_sys->stream.i_read_size );
- if( p_sys->stream.i_read_size <= 0 )
- p_sys->stream.i_read_size = STREAM_READ_ATONCE;
- else if( p_sys->stream.i_read_size <= 256 )
- p_sys->stream.i_read_size = 256;
+ p_sys->stream.i_read_size = STREAM_READ_ATONCE;
+#if STREAM_READ_ATONCE < 256
+# error "Invalid STREAM_READ_ATONCE value"
+#endif
for( i = 0; i < STREAM_CACHE_TRACK; i++ )
{
while( p_sys->i_list > 0 )
free( p_sys->list[--(p_sys->i_list)] );
free( p_sys->list );
- free( psz_list );
free( s->p_sys );
vlc_object_detach( s );
stream_CommonDelete( s );
return VLC_EGENERIC;
}
- case STREAM_GET_MTU:
- return VLC_EGENERIC;
-
case STREAM_CONTROL_ACCESS:
{
i_int = (int) va_arg( args, int );
static void AStreamPrebufferBlock( stream_t *s )
{
stream_sys_t *p_sys = s->p_sys;
- access_t *p_access = p_sys->p_access;
int64_t i_first = 0;
int64_t i_start;
}
while( p_sys->block.i_start + p_sys->block.i_size < i_pos );
- p_sys->block.i_offset = i_pos - p_sys->i_pos;
+ p_sys->block.i_offset += i_pos - p_sys->i_pos;
p_sys->i_pos = i_pos;
return VLC_SUCCESS;
static int AStreamRefillBlock( stream_t *s )
{
stream_sys_t *p_sys = s->p_sys;
- int64_t i_start, i_stop;
block_t *b;
/* Release data */
}
/* Now read a new block */
- i_start = mdate();
+ const int64_t i_start = mdate();
for( ;; )
{
bool b_eof;
return VLC_EGENERIC;
}
+ p_sys->stat.i_read_time += mdate() - i_start;
while( b )
{
- i_stop = mdate();
-
/* Append the block */
p_sys->block.i_size += b->i_buffer;
*p_sys->block.pp_last = b;
/* Update stat */
p_sys->stat.i_bytes += b->i_buffer;
- p_sys->stat.i_read_time += i_stop - i_start;
p_sys->stat.i_read_count++;
b = b->p_next;
- i_start = mdate();
}
return VLC_SUCCESS;
}
static void AStreamPrebufferStream( stream_t *s )
{
stream_sys_t *p_sys = s->p_sys;
- access_t *p_access = p_sys->p_access;
int64_t i_first = 0;
int64_t i_start;
int i_total = 0;
if( s->p_parent && s->p_parent->p_parent &&
- s->p_parent->p_parent->i_object_type == VLC_OBJECT_INPUT )
+ vlc_internals( s->p_parent->p_parent )->i_object_type == VLC_OBJECT_INPUT )
p_input = (input_thread_t *)s->p_parent->p_parent;
if( !p_sys->i_list )
int i_total = 0;
if( s->p_parent && s->p_parent->p_parent &&
- s->p_parent->p_parent->i_object_type == VLC_OBJECT_INPUT )
+ vlc_internals( s->p_parent->p_parent )->i_object_type == VLC_OBJECT_INPUT )
p_input = (input_thread_t *)s->p_parent->p_parent;
if( !p_sys->i_list )