Skip to contentSkip to conversation

alsa-libs: use CLOCK_REALTIME for non-monotonic ts

PATCH Applied Olivier Langlois 2 participants 2 messages Jan 24, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alsa-libs: use CLOCK_REALTIME for non-monotonic ts

gettimeofday() is the same than clock_gettime(CLOCK_REALTIME) except for the loss of precision and the double unnecessary conversion timespec <-> timeval.

---
 src/pcm/pcm_local.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
src/pcm/pcm_local.h +6 -2
index e1c0baa..8a6c743 100644
@@ -961,17 +961,21 @@ typedef union snd_tmp_double {
 /* get the current timestamp */
 static inline void gettimestamp(snd_htimestamp_t *tstamp, int monotonic)
 {
-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
+#if defined(HAVE_CLOCK_GETTIME)
+#if defined(CLOCK_MONOTONIC)
 	if (monotonic) {
 		clock_gettime(CLOCK_MONOTONIC, tstamp);
 	} else {
 #endif
+		clock_gettime(CLOCK_REALTIME, tstamp);
+#else
 		struct timeval tv;
 
 		gettimeofday(&tv, 0);
 		tstamp->tv_sec = tv.tv_sec;
 		tstamp->tv_nsec = tv.tv_usec * 1000L;
-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
+#endif
+#if defined(HAVE_CLOCK_GETTIME)
 	}
 #endif
 }
Signature · 1 line
1.8.5.3
Applied
#1 lore raw

At Thu, 23 Jan 2014 19:03:00 -0500,

Quoted 6 lines · Olivier Langlois

gettimeofday() is the same than clock_gettime(CLOCK_REALTIME) except for the loss of precision and the double unnecessary conversion timespec <-> timeval.

Thanks, applied.

Takashi

Quoted 40 lines
---
 src/pcm/pcm_local.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
src/pcm/pcm_local.h +6 -2
index e1c0baa..8a6c743 100644
@@ -961,17 +961,21 @@ typedef union snd_tmp_double {
 /* get the current timestamp */
 static inline void gettimestamp(snd_htimestamp_t *tstamp, int monotonic)
 {
-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
+#if defined(HAVE_CLOCK_GETTIME)
+#if defined(CLOCK_MONOTONIC)
 	if (monotonic) {
 		clock_gettime(CLOCK_MONOTONIC, tstamp);
 	} else {
 #endif
+		clock_gettime(CLOCK_REALTIME, tstamp);
+#else
 		struct timeval tv;
 
 		gettimeofday(&tv, 0);
 		tstamp->tv_sec = tv.tv_sec;
 		tstamp->tv_nsec = tv.tv_usec * 1000L;
-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
+#endif
+#if defined(HAVE_CLOCK_GETTIME)
 	}
 #endif
 }
Signature · 6 lines
1.8.5.3

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel