summaryrefslogtreecommitdiff
path: root/misc.h
diff options
context:
space:
mode:
authorJohns <johns98@gmx.net>2012-03-05 17:34:10 +0100
committerJohns <johns98@gmx.net>2012-03-05 17:34:10 +0100
commit4cc98d7937de1d3594209e34136515619a6b87f8 (patch)
tree466c6fe6285f91f0201910972fde97105eb87618 /misc.h
parent3812fa8d38d0fea3ec2f629c90e5fe943c70a926 (diff)
downloadvdr-plugin-softhddevice-4cc98d7937de1d3594209e34136515619a6b87f8.tar.gz
vdr-plugin-softhddevice-4cc98d7937de1d3594209e34136515619a6b87f8.tar.bz2
Move time-stamp printing to misc.h.
Diffstat (limited to 'misc.h')
-rw-r--r--misc.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/misc.h b/misc.h
index 1cfa88d..5e32e39 100644
--- a/misc.h
+++ b/misc.h
@@ -107,6 +107,31 @@ static inline void Syslog(const int level, const char *format, ...)
#define Debug(level, fmt...) /* disabled */
#endif
+#ifdef AV_NOPTS_VALUE
+
+/**
+** Nice time-stamp string.
+**
+** @param ts dvb time stamp
+*/
+static inline const char *Timestamp2String(int64_t ts)
+{
+ static char buf[4][16];
+ static int idx;
+
+ if (ts == (int64_t) AV_NOPTS_VALUE) {
+ return "--:--:--.---";
+ }
+ idx = (idx + 1) % 3;
+ snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d",
+ (int)(ts / (90 * 3600000)), (int)((ts / (90 * 60000)) % 60),
+ (int)((ts / (90 * 1000)) % 60), (int)((ts / 90) % 1000));
+
+ return buf[idx];
+}
+
+#endif
+
/**
** Get ticks in ms.
**