From 810124041268e4f0b20d271ddc566d11ecb8575f Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Thu, 22 Aug 2013 15:11:48 -0700 Subject: pcm_get_htimestamp can now use CLOCK_MONOTONIC Previously the timebase was not documented. Now a new pcm_open flag can be used to specify the clock. If flag PCM_MONOTONIC is specified, then pcm_open uses SNDRV_PCM_IOCTL_TTSTAMP with parameter SNDRV_PCM_TSTAMP_TYPE_MONOTONIC to request timestamps in CLOCK_MONOTONIC. Change-Id: I40ce359cb38d686cbb2521fb0602a8a17ab4f925 --- pcm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pcm.c') diff --git a/pcm.c b/pcm.c index ca3eb3e..8195c7c 100644 --- a/pcm.c +++ b/pcm.c @@ -719,6 +719,17 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, goto fail; } +#ifdef SNDRV_PCM_IOCTL_TTSTAMP + if (pcm->flags & PCM_MONOTONIC) { + int arg = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC; + rc = ioctl(pcm->fd, SNDRV_PCM_IOCTL_TTSTAMP, &arg); + if (rc < 0) { + oops(pcm, rc, "cannot set timestamp type"); + goto fail; + } + } +#endif + pcm->underruns = 0; return pcm; -- cgit v1.2.3