[MPlayer-dev-eng] sub/a-v delay display rounding

Oskar Liljeblad oskar at osk.mine.nu
Sat Nov 30 15:54:11 CET 2002


Hello

This patch prevents sub and A-V delays from being displayed as
-2799 ms instead of -2800 ms etc. Let me know if this patch is
applied or not.

Note: apparently round and lround only officially exist in C99
according to gcc. Therefore it is necessary to define
_ISOC99_SOURCE. And when you do this, BSD functions aren't
included by default. So you have to define _BSD_SOURCE as well.
You won't notice this though unless you compile with -Wall.

Oskar Liljeblad (oskar at osk.mine.nu)

--- mplayer.c.orig      2002-11-29 01:58:06.000000000 +0100
+++ mplayer.c   2002-11-30 15:51:11.000000000 +0100
@@ -1,9 +1,12 @@
 // Movie Player    v0.90   (C) 2000-2002. by A'rpi/ESP-team & `cat AUTHORS`
 
+#define _ISOC99_SOURCE // for lround
+#define _BSD_SOURCE    // for usleep with _ISOC99_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <math.h>      // for lround
 
 #include <sys/ioctl.h>
 // #include <sys/mman.h>
@@ -2719,11 +2722,11 @@
          osd_show_vobsub_changed--;
       } else
       if (osd_show_sub_delay) {
-         sprintf(osd_text_tmp, "Sub delay: %d ms",(int)(sub_delay*1000));
+         sprintf(osd_text_tmp, "Sub delay: %ld ms", lround(sub_delay*1000));
          osd_show_sub_delay--;
       } else
       if (osd_show_av_delay) {
-         sprintf(osd_text_tmp, "A-V delay: %d ms",(int)(audio_delay*1000));
+         sprintf(osd_text_tmp, "A-V delay: %ld ms", lround(audio_delay*1000));
          osd_show_av_delay--;
       } else if(osd_level>=2)
           sprintf(osd_text_tmp,"%c %02d:%02d:%02d",osd_function,pts/3600,(pts/60)%60,pts%60);



More information about the MPlayer-dev-eng mailing list