pcm: Implement timestamp type handling in all plugins

Now all PCM plugins do support the proper timestamp type or pass it
over slaves.  The internal monotonic flag is dropped and replaced with
tstamp_type in all places.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2014-07-10 14:37:49 +02:00
parent 9b716075de
commit 65ff6fdafb
28 changed files with 73 additions and 58 deletions

View file

@ -191,7 +191,6 @@ struct _snd_pcm {
int poll_fd;
unsigned short poll_events;
int setup: 1,
monotonic: 1,
compat: 1;
snd_pcm_access_t access; /* access mode */
snd_pcm_format_t format; /* SND_PCM_FORMAT_* */
@ -960,26 +959,40 @@ typedef union snd_tmp_double {
} snd_tmp_double_t;
/* get the current timestamp */
static inline void gettimestamp(snd_htimestamp_t *tstamp, int monotonic)
#ifdef HAVE_CLOCK_GETTIME
static inline void gettimestamp(snd_htimestamp_t *tstamp,
snd_pcm_tstamp_type_t tstamp_type)
{
#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;
clockid_t id;
gettimeofday(&tv, 0);
tstamp->tv_sec = tv.tv_sec;
tstamp->tv_nsec = tv.tv_usec * 1000L;
switch (tstamp_type) {
#ifdef CLOCK_MONOTONIC_RAW
case SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
id = CLOCK_MONOTONIC_RAW;
break;
#endif
#if defined(HAVE_CLOCK_GETTIME)
#ifdef CLOCK_MONOTONIC
case SND_PCM_TSTAMP_TYPE_MONOTONIC:
id = CLOCK_MONOTONIC;
break;
#endif
default:
id = CLOCK_REALTIME;
break;
}
#endif
clock_gettime(id, tstamp);
}
#else /* HAVE_CLOCK_GETTIME */
static inline void gettimestamp(snd_htimestamp_t *tstamp,
snd_pcm_tstamp_type_t tstamp_type)
{
struct timeval tv;
gettimeofday(&tv, 0);
tstamp->tv_sec = tv.tv_sec;
tstamp->tv_nsec = tv.tv_usec * 1000L;
}
#endif /* HAVE_CLOCK_GETTIME */
snd_pcm_chmap_query_t **
_snd_pcm_make_single_query_chmaps(const snd_pcm_chmap_t *src);