Commit 2e4d57cf authored by Laurent Aimar's avatar Laurent Aimar

Fixed flac demuxer segfault (/0) when seektable is empty.

parent 9aba8655
...@@ -283,10 +283,7 @@ static int64_t ControlGetTime( demux_t *p_demux ) ...@@ -283,10 +283,7 @@ static int64_t ControlGetTime( demux_t *p_demux )
static int ControlSetTime( demux_t *p_demux, int64_t i_time ) static int ControlSetTime( demux_t *p_demux, int64_t i_time )
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
int64_t i_next_time;
int64_t i_next_offset;
int64_t i_delta_time; int64_t i_delta_time;
int64_t i_delta_offset;
bool b_seekable; bool b_seekable;
int i; int i;
...@@ -302,33 +299,43 @@ static int ControlSetTime( demux_t *p_demux, int64_t i_time ) ...@@ -302,33 +299,43 @@ static int ControlSetTime( demux_t *p_demux, int64_t i_time )
if( p_sys->seekpoint[i]->i_time_offset <= i_time ) if( p_sys->seekpoint[i]->i_time_offset <= i_time )
break; break;
} }
if( i+1 < p_sys->i_seekpoint )
{
i_next_time = p_sys->seekpoint[i+1]->i_time_offset;
i_next_offset = p_sys->seekpoint[i+1]->i_byte_offset;
}
else
{
i_next_time = p_sys->i_length;
i_next_offset = stream_Size(p_demux->s)-p_sys->i_data_pos;
}
i_delta_time = i_time - p_sys->seekpoint[i]->i_time_offset; i_delta_time = i_time - p_sys->seekpoint[i]->i_time_offset;
i_delta_offset = (i_next_offset - p_sys->seekpoint[i]->i_byte_offset) * i_delta_time /
(p_sys->seekpoint[i+1]->i_time_offset-p_sys->seekpoint[i]->i_time_offset);
/* XXX We do exact seek if it's not too far away(45s) */ /* XXX We do exact seek if it's not too far away(45s) */
if( i_delta_time < 45*INT64_C(1000000) ) if( i_delta_time < 45*INT64_C(1000000) )
{ {
if( stream_Seek( p_demux->s, p_sys->seekpoint[i]->i_byte_offset+p_sys->i_data_pos ) ) if( stream_Seek( p_demux->s, p_sys->seekpoint[i]->i_byte_offset+p_sys->i_data_pos ) )
return VLC_EGENERIC; return VLC_EGENERIC;
p_sys->i_time_offset = p_sys->seekpoint[i]->i_time_offset - p_sys->i_pts; p_sys->i_time_offset = p_sys->seekpoint[i]->i_time_offset - p_sys->i_pts;
p_sys->i_pts_start = p_sys->i_pts+i_delta_time; p_sys->i_pts_start = p_sys->i_pts+i_delta_time;
es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, p_sys->p_es, p_sys->i_pts_start ); es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, p_sys->p_es, p_sys->i_pts_start );
} }
else else
{ {
int64_t i_delta_offset;
int64_t i_next_time;
int64_t i_next_offset;
if( i+1 < p_sys->i_seekpoint )
{
i_next_time = p_sys->seekpoint[i+1]->i_time_offset;
i_next_offset = p_sys->seekpoint[i+1]->i_byte_offset;
}
else
{
i_next_time = p_sys->i_length;
i_next_offset = stream_Size(p_demux->s)-p_sys->i_data_pos;
}
i_delta_offset = 0;
if( i_next_time-p_sys->seekpoint[i]->i_time_offset > 0 )
i_delta_offset = (i_next_offset - p_sys->seekpoint[i]->i_byte_offset) * i_delta_time /
(i_next_time-p_sys->seekpoint[i]->i_time_offset);
if( stream_Seek( p_demux->s, p_sys->seekpoint[i]->i_byte_offset+p_sys->i_data_pos + i_delta_offset ) ) if( stream_Seek( p_demux->s, p_sys->seekpoint[i]->i_byte_offset+p_sys->i_data_pos + i_delta_offset ) )
return VLC_EGENERIC; return VLC_EGENERIC;
p_sys->i_pts_start = p_sys->i_pts; p_sys->i_pts_start = p_sys->i_pts;
p_sys->i_time_offset = (p_sys->seekpoint[i]->i_time_offset+i_delta_time) - p_sys->i_pts; p_sys->i_time_offset = (p_sys->seekpoint[i]->i_time_offset+i_delta_time) - p_sys->i_pts;
} }
......
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