From b751eef1fdffca5532344285f2fad0c60d2f0158 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 13 Dec 2007 10:19:42 +0100 Subject: [ALSA] Use posix clock monotonic for PCM and timer timestamps We need an accurate and continuous (monotonic) time sources to do accurate synchronization among more timing sources. This patch allows to enable monotonic timestamps for ALSA PCM devices and enables monotonic timestamps for ALSA timer devices. Signed-off-by: Jaroslav Kysela --- include/sound/pcm.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/sound/pcm.h') diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 5e9cc460075..65f636223d3 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -323,6 +323,7 @@ struct snd_pcm_runtime { /* -- timer -- */ unsigned int timer_resolution; /* timer resolution */ + int tstamp_type; /* timestamp type */ /* -- DMA -- */ unsigned char *dma_area; /* DMA area */ @@ -952,6 +953,15 @@ void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream); void snd_pcm_timer_init(struct snd_pcm_substream *substream); void snd_pcm_timer_done(struct snd_pcm_substream *substream); +static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime, + struct timespec *tv) +{ + if (runtime->tstamp_type == SNDRV_PCM_TSTAMP_TYPE_MONOTONIC) + do_posix_clock_monotonic_gettime(tv); + else + getnstimeofday(tv); +} + /* * Memory */ -- cgit v1.2.3-70-g09d2