[vlc-devel] commit: ps: fix division by zero when seeking (fixes #2633) ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Apr 5 13:44:08 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr  5 14:42:37 2009 +0300| [9ad7f61f78c566792ef30c9218e6785f48efb621] | committer: Rémi Denis-Courmont 

ps: fix division by zero when seeking (fixes #2633)

That happened when seeking during the first second of playback.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9ad7f61f78c566792ef30c9218e6785f48efb621
---

 modules/demux/ps.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/demux/ps.c b/modules/demux/ps.c
index e2b6c37..e9abecc 100644
--- a/modules/demux/ps.c
+++ b/modules/demux/ps.c
@@ -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;




More information about the vlc-devel mailing list