pcm: hw: do not reset tstamp_type in SND_PCM_APPEND mode (#2)

This is basically redo of all changed and add appropriate conditions
to disable only ioctl calls, but preserve tstamp_type assignments.

Fixes: 15f2b276 ("pcm: hw: fix default timestamp type for O_APPPEND")
Fixes: 7e01443e ("pcm: hw: do not reset tstamp_type in SND_PCM_APPEND mode")
Link: https://github.com/alsa-project/alsa-lib/pull/450
Suggested-by: Signed-off-by: Kevin Groeneveld <kgroeneveld@lenbrook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2025-04-08 11:18:16 +02:00
parent 15f2b27612
commit 8b75db9676

View file

@ -1665,22 +1665,23 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
}
}
if (!(mode & SND_PCM_APPEND)) {
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
if (SNDRV_PROTOCOL_VERSION(2, 0, 9) <= ver) {
struct timespec timespec;
if (clock_gettime(CLOCK_MONOTONIC, &timespec) == 0) {
if (!(mode & SND_PCM_APPEND)) {
int on = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
if (ioctl(fd, SNDRV_PCM_IOCTL_TTSTAMP, &on) < 0) {
ret = -errno;
SNDMSG("TTSTAMP failed");
return ret;
}
}
tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
}
} else
#endif
if (SNDRV_PROTOCOL_VERSION(2, 0, 5) <= ver) {
if (SNDRV_PROTOCOL_VERSION(2, 0, 5) <= ver && !(mode & SND_PCM_APPEND)) {
int on = 1;
if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) {
ret = -errno;
@ -1688,13 +1689,6 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
return ret;
}
}
}
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
else {
/* the first stream already sets this */
tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
}
#endif
hw = calloc(1, sizeof(snd_pcm_hw_t));
if (!hw) {