Commit 1aaa17eb authored by François Cartegnie's avatar François Cartegnie 🤞

demux: ogg: fix broken bisection on invalid granule

happens when seeking outside of stream/on new stream ahead
parent 249c1e41
......@@ -875,8 +875,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if ( p_sys->i_length <= 0 || !b /* || ! STREAM_CAN_FASTSEEK */ )
{
Ogg_ResetStreamsHelper( p_sys );
Oggseek_BlindSeektoPosition( p_demux, p_stream, f, b );
return VLC_SUCCESS;
return Oggseek_BlindSeektoPosition( p_demux, p_stream, f, b );
}
assert( p_sys->i_length > 0 );
......
......@@ -950,6 +950,7 @@ int Oggseek_BlindSeektoPosition( demux_t *p_demux, logical_stream_t *p_stream,
demux_sys_t *p_sys = p_demux->p_sys;
OggDebug( msg_Dbg( p_demux, "=================== Seeking To Blind Pos" ) );
int64_t i_size = stream_Size( p_demux->s );
uint64_t i_startpos = vlc_stream_Tell( p_demux->s );
int64_t i_granule;
int64_t i_pagepos;
......@@ -957,6 +958,12 @@ int Oggseek_BlindSeektoPosition( demux_t *p_demux, logical_stream_t *p_stream,
i_size * f, i_size,
p_stream,
&i_granule );
if( i_granule == -1 )
{
if( vlc_stream_Seek( p_demux->s, i_startpos ) != VLC_SUCCESS )
msg_Err( p_demux, "Seek back failed. Not seekable ?" );
return VLC_EGENERIC;
}
OggDebug( msg_Dbg( p_demux, "Seek start pos is %"PRId64" granule %"PRId64, i_size, i_granule ) );
......@@ -981,7 +988,7 @@ int Oggseek_BlindSeektoPosition( demux_t *p_demux, logical_stream_t *p_stream,
}
OggDebug( msg_Dbg( p_demux, "=================== Seeked To %"PRId64" granule %"PRId64, i_pagepos, i_granule ) );
return i_pagepos;
return VLC_SUCCESS;
}
int Oggseek_SeektoAbsolutetime( demux_t *p_demux, logical_stream_t *p_stream,
......
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