{
demux_sys_t *p_sys = p_demux->p_sys;
- unsigned int i_stream;
msg_Dbg( p_demux, "seek requested: %"PRId64" seconds %d%%",
i_date / 1000000, i_percent );
if( p_sys->b_seekable )
{
+ unsigned i_stream;
+
if( !p_sys->i_length )
{
- avi_track_t *p_stream;
+ avi_track_t *p_stream = NULL;
int64_t i_pos;
/* use i_percent to create a true i_date */
/* try to find chunk that is at i_percent or the file */
i_pos = __MAX( i_percent * stream_Size( p_demux->s ) / 100,
p_sys->i_movi_begin );
- /* search first selected stream (and prefer non eof ones) */
- for( i_stream = 0, p_stream = NULL;
- i_stream < p_sys->i_track; i_stream++ )
+ /* search first selected stream (and prefer non-EOF ones) */
+ for( unsigned i = 0; i < p_sys->i_track; i++ )
{
- if( !p_stream || p_stream->b_eof )
- p_stream = p_sys->track[i_stream];
+ avi_track_t *p_track = p_sys->track[i];
+ if( !p_track->b_activated )
+ continue;
- if( p_stream->b_activated && !p_stream->b_eof )
+ p_stream = p_track;
+ i_stream = i;
+ if( !p_track->b_eof )
break;
}
- if( !p_stream || !p_stream->b_activated )
+ if( p_stream == NULL )
{
msg_Warn( p_demux, "cannot find any selected stream" );
return VLC_EGENERIC;