[MPlayer-dev-eng] [PATCH] total time for audio-only files

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Mon Oct 3 15:08:31 CEST 2005


Hi,
the attached patch makes MPlayer display the total time in the status
line for audio-only files. I think this is useful for audio-only since
1) the status line is still quite small
2) you can't just activate the OSD to find the total time

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.872
diff -u -r1.872 mplayer.c
--- mplayer.c	19 Sep 2005 16:33:38 -0000	1.872
+++ mplayer.c	2 Oct 2005 14:43:26 -0000
@@ -846,6 +846,30 @@
 }
 
 /**
+ * \brief append time in the hh:mm:ss.f format
+ * \param buf buffer to print into
+ * \param pos position of terminating 0 in buf
+ * \param len maximum number of characters in buf, not including terminating 0
+ * \param time time value to convert/append
+ */
+static void sadd_hhmmssf(char *buf, unsigned *pos, int len, float time) {
+  long tenths = 10 * time;
+  int f1 = tenths % 10;
+  int ss = (tenths /  10) % 60;
+  int mm = (tenths / 600) % 60;
+  int hh = tenths / 36000;
+  if (time <= 0) {
+    saddf(buf, pos, len, "unknown");
+    return;
+  }
+  if (hh > 0)
+    saddf(buf, pos, len, "%2d:", hh);
+  if (hh > 0 || mm > 0)
+    saddf(buf, pos, len, "%02d:", mm);
+  saddf(buf, pos, len, "%02d.%1d", ss, f1);
+}
+
+/**
  * \brief print the status line
  * \param a_pos audio position
  * \param a_v A-V desynchronization
@@ -872,20 +896,12 @@
   if (sh_audio) {
     saddf(line, &pos, width, "A:%6.1f ", a_pos);
     if (!sh_video) {
-      // convert time to HH:MM:SS.F format
-      long tenths = 10 * a_pos;
-      int f1 = tenths % 10;
-      int ss = (tenths /  10) % 60;
-      int mm = (tenths / 600) % 60;
-      int hh = (tenths / 36000) % 100;
+      float len = demuxer_get_time_length(demuxer);
       saddf(line, &pos, width, "(");
-      if (hh > 0)
-        saddf(line, &pos, width, "%2d:", hh);
-      if (hh > 0 || mm > 0)
-        saddf(line, &pos, width, "%02d:", mm);
-      saddf(line, &pos, width, "%02d.", ss);
-      saddf(line, &pos, width, "%1d", f1);
-      saddf(line, &pos, width, ") ");
+      sadd_hhmmssf(line, &pos, width, a_pos);
+      saddf(line, &pos, width, ") of %.1f (", len);
+      sadd_hhmmssf(line, &pos, width, len);
+      saddf(line, &pos, width, ")");
     }
   }
 


More information about the MPlayer-dev-eng mailing list