mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
check availability of CLOCK_MONOTONIC
Use monotonic timestamps only after checking that CLOCK_MONOTONIC is actually supported by the C library.
This commit is contained in:
parent
07e1341548
commit
0e8a259914
2 changed files with 16 additions and 7 deletions
|
|
@ -996,13 +996,16 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
|
|||
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
if (SNDRV_PROTOCOL_VERSION(2, 0, 9) <= ver) {
|
||||
int on = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
|
||||
if (ioctl(fd, SNDRV_PCM_IOCTL_TTSTAMP, &on) < 0) {
|
||||
ret = -errno;
|
||||
SNDMSG("TTSTAMP failed\n");
|
||||
return ret;
|
||||
struct timespec timespec;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, ×pec) == 0) {
|
||||
int on = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
|
||||
if (ioctl(fd, SNDRV_PCM_IOCTL_TTSTAMP, &on) < 0) {
|
||||
ret = -errno;
|
||||
SNDMSG("TTSTAMP failed\n");
|
||||
return ret;
|
||||
}
|
||||
monotonic = 1;
|
||||
}
|
||||
monotonic = 1;
|
||||
}
|
||||
#endif
|
||||
else if (SNDRV_PROTOCOL_VERSION(2, 0, 5) <= ver) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue