]> git.sesse.net Git - vlc/blobdiff - src/misc/mtime.c
item: fix undefined zero-size array
[vlc] / src / misc / mtime.c
index da0d8bfc374f0f4f5fe17760b8001cd88bcea91f..62409edd6b944bc7beb359c5b96f2c9c73e41845 100644 (file)
@@ -2,7 +2,7 @@
  * mtime.c: high resolution time management functions
  * Functions are prototyped in vlc_mtime.h.
  *****************************************************************************
- * Copyright (C) 1998-2007 the VideoLAN team
+ * Copyright (C) 1998-2007 VLC authors and VideoLAN
  * Copyright © 2006-2007 Rémi Denis-Courmont
  * $Id$
  *
  *          Rémi Denis-Courmont <rem$videolan,org>
  *          Gisle Vanem
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
 #include <vlc_common.h>
 #include <assert.h>
 
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#if !defined (_POSIX_TIMERS)
+#include <unistd.h>
+#if !defined (_POSIX_TIMERS) || defined (_WIN32)
 # define _POSIX_TIMERS (-1)
 #endif
 #if (_POSIX_TIMERS > 0)
@@ -212,14 +210,14 @@ mtime_t date_Increment( date_t *p_date, uint32_t i_nb_samples )
  */
 mtime_t date_Decrement( date_t *p_date, uint32_t i_nb_samples )
 {
-    mtime_t i_dividend = (mtime_t)i_nb_samples * 1000000 * p_date->i_divider_den;
+    mtime_t i_dividend = (mtime_t)i_nb_samples * CLOCK_FREQ * p_date->i_divider_den;
     p_date->date -= i_dividend / p_date->i_divider_num;
     unsigned i_rem_adjust = i_dividend % p_date->i_divider_num;
 
     if( p_date->i_remainder < i_rem_adjust )
     {
         /* This is Bresenham algorithm. */
-        assert( p_date->i_remainder > -p_date->i_divider_num);
+        assert( p_date->i_remainder p_date->i_divider_num);
         p_date->date -= 1;
         p_date->i_remainder += p_date->i_divider_num;
     }