]> git.sesse.net Git - vlc/commitdiff
* include/mtime.h :
authorMichel Kaempf <maxx@videolan.org>
Wed, 29 Sep 1999 09:56:04 +0000 (09:56 +0000)
committerMichel Kaempf <maxx@videolan.org>
Wed, 29 Sep 1999 09:56:04 +0000 (09:56 +0000)
- mtime_t devient un s64 (et non plus un u64) pour harmoniser gestion de
l'horloge et synchronisation ;
- LAST_MDATE correspond d�sormais � la plus grande valeur que peut
prendre un s64 ;
- MSTRTIME_MAX_SIZE prend en compte le fait que les dates peuvent d�sormais
�tre n�gatives ;

* misc/mtime.c :
- modifications diverses et vari�es prenant en compte le changement de
mtime_t ;

* include/input.h :
- i_pts et les variables s64 de la structure pcr sont d�sormais des mtime_t ;

* input/input.c :
- passage des casts en (mtime_t) et non (s64) ;

* input/input_file.c :
- rajout d'un #include "mtime.h" ;

* input/input_pcr.c :
- passage des s64 en mtime_t ;

* misc/xutils.c :
- correction de deux warnings ;

-- MaXX

include/input.h
include/mtime.h
src/input/input.c
src/input/input_file.c
src/input/input_pcr.c
src/misc/mtime.c
src/misc/xutils.c

index 9c907740a0d8b49aef3b06935bbb77c9b6804eec..e08240c277bacdc3f332968378c5ff92dcaf4a9d 100644 (file)
@@ -3,7 +3,7 @@
  * (c)1999 VideoLAN
  *******************************************************************************/
 
-/* needs : "netlist.h", "config.h" */
+/* needs : "netlist.h", "config.h", "mtime.h" */
 
 /* ?? missing: 
  *              tables version control */
@@ -60,7 +60,7 @@ typedef struct
     boolean_t               b_data_alignment;  /* used to find the beginning of a
                                                 * video or audio unit          */
     boolean_t               b_has_pts;         /* is the following field set ? */
-    s64                     i_pts;   /* the PTS for this packet (if set above) */
+    mtime_t                 i_pts;   /* the PTS for this packet (if set above) */
     boolean_t               b_random_access;
               /* if TRUE, in the payload of this packet, there is the first byte 
                * of a video sequence header, or the first byte of an audio frame.
@@ -209,8 +209,8 @@ typedef struct pcr_descriptor_struct
 {
     pthread_mutex_t         lock;                     /* pcr modification lock */
 
-    s64                     delta_clock;
-    s64                     delta_decode;
+    mtime_t                 delta_clock;
+    mtime_t                 delta_decode;
                             /* represents decoder_time - pcr_time in usecondes */
     count_t                 c_average;
                              /* counter used to compute dynamic average values */
@@ -218,10 +218,10 @@ typedef struct pcr_descriptor_struct
 #ifdef STATS
     /* Stats */
     count_t     c_average_jitter;
-    s64         max_jitter;                    /* the evalueted maximum jitter */
-    s64         average_jitter;                /* the evalueted average jitter */
+    mtime_t     max_jitter;                    /* the evalueted maximum jitter */
+    mtime_t     average_jitter;                /* the evalueted average jitter */
     count_t     c_pcr;            /* the number of PCR which have been decoded */
-#endif    
+#endif
 } pcr_descriptor_t;
 
 /*******************************************************************************
index b4ea319c310cc0cb3ac125bbb302085b2cf6b4b5..cbc74b09c6e270452e50389a4cc3526e0562330a 100644 (file)
  *******************************************************************************
  * Store an high precision date or time interval. The maximum precision is the
  * micro-second, and a 64 bits integer is used to avoid any overflow (maximum
- * time interval is then 584542 years, which should be length enough for any
+ * time interval is then 292271 years, which should be length enough for any
  * video). Date are stored as a time interval since a common date.
- * Note than date and time intervals can be manipulated using regular arithmetic
+ * Note that date and time intervals can be manipulated using regular arithmetic
  * operators, and that no special functions are required.
  *******************************************************************************/
-typedef u64 mtime_t;
+typedef s64 mtime_t;
 
 /*******************************************************************************
  * LAST_MDATE: date which will never happen
@@ -35,16 +35,16 @@ typedef u64 mtime_t;
  * returning the date of the first image to be displayed. It can be used in
  * comparaison with other values: all existing dates will be earlier.
  *******************************************************************************/
-#define LAST_MDATE          ((mtime_t) -1)
+#define LAST_MDATE ((mtime_t)((u64)(-1)/2))
 
 /*******************************************************************************
  * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
  *******************************************************************************
  * This values is the maximal possible size of the string returned by the
- * mstrtime() function, including the final '\0'. It should be used to allocate
- * the buffer.
+ * mstrtime() function, including '-' and the final '\0'. It should be used to
+ * allocate the buffer.
  *******************************************************************************/
-#define MSTRTIME_MAX_SIZE   20
+#define MSTRTIME_MAX_SIZE 22
 
 /*******************************************************************************
  * Prototypes
index 6116673d0359c926d20281be5fd6865efd63055f..489892ac1f9213becf10addbd0c77bb9829f7975 100644 (file)
@@ -882,16 +882,16 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
                     }
                     else
                     {
-                        p_pes->i_pts = ( ((s64)p_pes->p_pes_header[9] << 29) +
-                                         ((s64)U16_AT(p_pes->p_pes_header + 10) << 14) +
-                                         ((s64)U16_AT(p_pes->p_pes_header + 12) >> 1) -
+                        p_pes->i_pts = ( ((mtime_t)p_pes->p_pes_header[9] << 29) +
+                                         ((mtime_t)U16_AT(p_pes->p_pes_header + 10) << 14) +
+                                         ((mtime_t)U16_AT(p_pes->p_pes_header + 12) >> 1) -
                                          (1 << 14) - (1 << 29) );
                         p_pes->i_pts *= 300;
                         p_pes->i_pts /= 27;
                         p_pes->i_pts += p_pcr->delta_clock;
                         if( p_pcr->c_pts == 0 )
                         {
-                            p_pcr->delta_decode = (s64)mdate() - p_pes->i_pts + 500000;
+                            p_pcr->delta_decode = mdate() - p_pes->i_pts + 500000;
                         }
                         p_pes->i_pts += p_pcr->delta_decode;
                     }
index 47405a575dac7947d702e408662ebead5fea94ed..b078c87d9bd0fac4c6a710cda8aa5fd79d821769 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "common.h"
 #include "config.h"
+#include "mtime.h"
 
 #include "input.h"
 #include "input_file.h"
@@ -39,6 +40,3 @@ int input_FileRead( input_thread_t *p_input, const struct iovec *p_vector,
 void input_FileDestroyMethod( input_thread_t *p_input )
 {
 }
-
-
-
index bfefd19d323065526466b41d74298607e107096d..6b4fd04062aebe34f7b51274b08a961851f9ae72 100644 (file)
@@ -71,7 +71,7 @@ int input_PcrInit( input_thread_t *p_input )
 void input_PcrDecode( input_thread_t *p_input, es_descriptor_t *p_es,
                       u8* p_pcr_data )
 {
-    s64 pcr_time, sys_time, delta_clock;
+    mtime_t pcr_time, sys_time, delta_clock;
     pcr_descriptor_t *p_pcr;
         
     ASSERT(p_pcr_data);
@@ -87,7 +87,7 @@ void input_PcrDecode( input_thread_t *p_input, es_descriptor_t *p_es,
     
     /* Express the PCR in microseconde
      * WARNING: do not remove the casts in the following calculation ! */
-    pcr_time = ( (( (s64)U32_AT((u32*)p_pcr_data) << 1 ) | ( p_pcr_data[4] >> 7 )) * 300 ) / 27;
+    pcr_time = ( (( (mtime_t)U32_AT((u32*)p_pcr_data) << 1 ) | ( p_pcr_data[4] >> 7 )) * 300 ) / 27;
     sys_time = mdate();
     delta_clock = sys_time - pcr_time;
     
@@ -109,7 +109,7 @@ void input_PcrDecode( input_thread_t *p_input, es_descriptor_t *p_es,
     
 #ifdef STATS
     {
-        s64 jitter;
+        mtime_t jitter;
         
         jitter = delta_clock - p_pcr->delta_clock;
         /* Compute the maximum jitter */
index 93c1b8b82a2e6e6d915aeba43a749cd7b80887d2..9b27f39cc024de857b7041b2f4bae69d808ef0ca 100644 (file)
@@ -1,52 +1,51 @@
-/*******************************************************************************
+/******************************************************************************
  * mtime.c: high rezolution time management functions
  * (c)1998 VideoLAN
- *******************************************************************************
+ ******************************************************************************
  * Functions are prototyped in mtime.h.
- *******************************************************************************
+ ******************************************************************************
  * to-do list:
  *  see if using Linux real-time extensions is possible and profitable
- *******************************************************************************/
+ ******************************************************************************/
 
-/*******************************************************************************
+/******************************************************************************
  * Preamble
- *******************************************************************************/
-
+ ******************************************************************************/
 #include <stdio.h>
 #include <sys/time.h>
 
 #include "common.h"
 #include "mtime.h"
 
-/*******************************************************************************
+/******************************************************************************
  * mstrtime: return a date in a readable format
- *******************************************************************************
+ ******************************************************************************
  * This functions is provided for any interface function which need to print a
  * date. psz_buffer should be a buffer long enough to store the formatted
- * date. 
- *******************************************************************************/
+ * date.
+ ******************************************************************************/
 char *mstrtime( char *psz_buffer, mtime_t date )
 {
-    sprintf( psz_buffer, "%02d:%02d:%02d-%03d.%03d", 
-             (int) (date / (1000UL * 1000UL * 60UL * 60UL) % 24UL), 
-             (int) (date / (1000UL * 1000UL * 60UL) % 60UL),
-             (int) (date / (1000UL * 1000UL) % 60UL),
-             (int) (date / 1000UL % 1000UL),
-             (int) (date % 1000UL) );
+    sprintf( psz_buffer, "%02d:%02d:%02d-%03d.%03d",
+             (int) (date / (1000LL * 1000LL * 60LL * 60LL) % 24LL),
+             (int) (date / (1000LL * 1000LL * 60LL) % 60LL),
+             (int) (date / (1000LL * 1000LL) % 60LL),
+             (int) (date / 1000LL % 1000LL),
+             (int) (date % 1000LL) );
     return( psz_buffer );
 }
 
-/*******************************************************************************
+/******************************************************************************
  * mdate: return high precision date (inline function)
- *******************************************************************************
+ ******************************************************************************
  * Uses the gettimeofday() function when possible (1 MHz resolution) or the
  * ftime() function (1 kHz resolution).
- *******************************************************************************
+ ******************************************************************************
  * to-do list: ??
  *  implement the function when gettimeofday is not available
  *  this function should be decalred as inline
- *******************************************************************************/
-mtime_t mdate( void ) 
+ ******************************************************************************/
+mtime_t mdate( void )
 {
     struct timeval tv_date;
 
@@ -57,48 +56,48 @@ mtime_t mdate( void )
     return( (mtime_t) tv_date.tv_sec * 1000000 + (mtime_t) tv_date.tv_usec );
 }
 
-/*******************************************************************************
- * mwait: wait for a date (inline function)                            
- *******************************************************************************
+/******************************************************************************
+ * mwait: wait for a date (inline function)
+ ******************************************************************************
  * This function uses select() and an system date function to wake up at a
  * precise date. It should be used for process synchronization. If current date
  * is posterior to wished date, the function returns immediately.
- *******************************************************************************
+ ******************************************************************************
  * to-do list:
  *  implement the function when gettimeofday is not available
  *  optimize delay calculation
  *  ?? declare as inline
- *******************************************************************************/
+ ******************************************************************************/
 void mwait( mtime_t date )
 {
     struct timeval tv_date, tv_delay;
-    s64            delay;            /* delay in msec, signed to detect errors */
+    mtime_t        delay;           /* delay in msec, signed to detect errors */
 
     /* see mdate() about gettimeofday() possible errors */
     gettimeofday( &tv_date, NULL );
 
     /* calculate delay and check if current date is before wished date */
     delay = date - (mtime_t) tv_date.tv_sec * 1000000 - (mtime_t) tv_date.tv_usec;
-    if( delay < 0 )                       /* wished date is already passed */
+    if( delay <= 0 )                  /* wished date is now or already passed */
     {
         return;
     }
     tv_delay.tv_sec = delay / 1000000;
-    tv_delay.tv_usec = delay % 1000000; 
-    
+    tv_delay.tv_usec = delay % 1000000;
+
     /* see msleep() about select() errors */
     select( 0, NULL, NULL, NULL, &tv_delay );
 }
 
-/*******************************************************************************
+/******************************************************************************
  * msleep: more precise sleep() (inline function)                        (ok ?)
- *******************************************************************************
+ ******************************************************************************
  * This function uses select() in a classical way to implement a sleep() call
- * with a microsecond precision. 
+ * with a microsecond precision.
  * For synchronization purposes, mwait() should be prefered.
- *******************************************************************************
+ ******************************************************************************
  * ?? decalre as inline
- *******************************************************************************/
+ ******************************************************************************/
 void msleep( mtime_t delay )
 {
     struct timeval tv_delay;
index 926b938fc1abd086fc853a3659a7268eaf96a8dc..73835438b5dff71bdda30071c5b1c2def508ca38 100644 (file)
@@ -60,6 +60,7 @@ int XTryLoadFont( Display *p_display, char *psz_font, XFontStruct **p_font )
 int XEnableScreenSaver( Display *p_display )
 {
     /* ?? */
+    return( 0 );
 }
 
 /*******************************************************************************
@@ -70,5 +71,5 @@ int XEnableScreenSaver( Display *p_display )
 int XDisableScreenSaver( Display *p_display )
 {
     /* ?? */
+    return( 0 );
 }
-