From: Olivier Langlois Subject: [PATCH] alsa-libs: use CLOCK_REALTIME for non-monotonic ts Date: Thu, 23 Jan 2014 19:03:00 -0500 Message-ID: <1390521780-14366-1-git-send-email-olivier@trillion01.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from alt-proxy11.mail.unifiedlayer.com (alt-proxy11.mail.unifiedlayer.com [74.220.211.241]) by alsa0.perex.cz (Postfix) with SMTP id A89952652E5 for ; Fri, 24 Jan 2014 01:04:16 +0100 (CET) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: patch@alsa-project.org Cc: Olivier Langlois , alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org gettimeofday() is the same than clock_gettime(CLOCK_REALTIME) except for the loss of precision and the double unnecessary conversion timespec <-> timeval. Signed-off-by: Olivier Langlois --- src/pcm/pcm_local.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index e1c0baa..8a6c743 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -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 } -- 1.8.5.3