Commit 8a9c9327 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: flac: fix pos/length on non zero starting flac

parent adb75830
...@@ -534,10 +534,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -534,10 +534,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
{ {
const double f = va_arg( args, double ); const double f = va_arg( args, double );
int64_t i_length = ControlGetLength( p_demux ); int64_t i_length = ControlGetLength( p_demux );
int i_ret;
if( i_length > 0 ) if( i_length > 0 )
return ControlSetTime( p_demux, i_length * f ); {
i_ret = ControlSetTime( p_demux, i_length * f );
if( i_ret == VLC_SUCCESS )
return i_ret;
}
/* just byte pos seek */ /* just byte pos seek */
int i_ret = vlc_stream_Seek( p_demux->s, (int64_t) (f * stream_Size( p_demux->s )) ); i_ret = vlc_stream_Seek( p_demux->s, (int64_t) (f * stream_Size( p_demux->s )) );
if( i_ret == VLC_SUCCESS ) if( i_ret == VLC_SUCCESS )
{ {
p_sys->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY; p_sys->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
...@@ -556,10 +561,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -556,10 +561,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
const int64_t i_length = ControlGetLength(p_demux); const int64_t i_length = ControlGetLength(p_demux);
if( i_length > 0 ) if( i_length > 0 )
{ {
double *pf = va_arg( args, double * );
double current = ControlGetTime(p_demux); double current = ControlGetTime(p_demux);
*pf = current / (double)i_length; if( current <= i_length )
return VLC_SUCCESS; {
*(va_arg( args, double * )) = current / (double)i_length;
return VLC_SUCCESS;
}
} }
/* Else fallback on byte position */ /* Else fallback on byte position */
} }
......
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