]> git.sesse.net Git - vlc/commitdiff
ps: fix division by zero when seeking (fixes #2633)
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 5 Apr 2009 11:42:37 +0000 (14:42 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 5 Apr 2009 11:42:37 +0000 (14:42 +0300)
That happened when seeking during the first second of playback.

modules/demux/ps.c

index e2b6c3774afa8e3319d27c23a3779bcbb002ff64..e9abeccf1b03519ad6d0abb2497dd048d9da11c7 100644 (file)
@@ -491,9 +491,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             {
                 int64_t i_now = p_sys->i_current_pts - p_sys->tk[p_sys->i_time_track].i_first_pts;
                 int64_t i_pos = stream_Tell( p_demux->s );
-                int64_t i_offset = i_pos / (i_now / 1000000) * ((i64 - i_now) / 1000000);
-                stream_Seek( p_demux->s, i_pos + i_offset);
 
+                if( !i_now )
+                    return i64 ? VLC_EGENERIC : VLC_SUCCESS;
+
+                i_pos *= (float)i64 / (float)i_now;
+                stream_Seek( p_demux->s, i_pos );
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;