[vlc-commits] commit: mtime: Avoid overflow when using mach_absolute_time(). (Pierre d' Herbemont )
git at videolan.org
git at videolan.org
Sat Sep 25 23:23:59 CEST 2010
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Sun Aug 1 12:48:49 2010 +0200| [532b014ad9c53a3ef32a74373fdb895726bde516] | committer: Pierre d'Herbemont
mtime: Avoid overflow when using mach_absolute_time().
Switch to double, do the operations and then convert back.
This fixes the iPad video freezes.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=532b014ad9c53a3ef32a74373fdb895726bde516
---
src/misc/mtime.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/misc/mtime.c b/src/misc/mtime.c
index 7341a66..80ed116 100644
--- a/src/misc/mtime.c
+++ b/src/misc/mtime.c
@@ -214,13 +214,13 @@ mtime_t mdate( void )
#elif defined( USE_APPLE_MACH )
pthread_once(&mtime_timebase_info_once, mtime_init_timebase);
uint64_t date = mach_absolute_time();
+ mach_timebase_info_data_t tb = mtime_timebase_info;
- /* Convert to nanoseconds */
- date *= mtime_timebase_info.numer;
- date /= mtime_timebase_info.denom;
-
+ /* Get the ssystem dependent factor. Switch to double to prevent overflow */
+ double factor = (double) tb.numer / (double) tb.denom;
/* Convert to microseconds */
- res = date / 1000;
+ double d = (double) date * factor / 1000;
+ res = d;
#elif defined( WIN32 ) || defined( UNDER_CE )
/* We don't need the real date, just the value of a high precision timer */
More information about the vlc-commits
mailing list