Skip to content

Commit 8b75db9

Browse files
committed
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: 15f2b27 ("pcm: hw: fix default timestamp type for O_APPPEND") Fixes: 7e01443 ("pcm: hw: do not reset tstamp_type in SND_PCM_APPEND mode") Link: alsa-project#450 Suggested-by: Signed-off-by: Kevin Groeneveld <kgroeneveld@lenbrook.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1 parent 15f2b27 commit 8b75db9

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

src/pcm/pcm_hw.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,36 +1665,30 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
16651665
}
16661666
}
16671667

1668-
if (!(mode & SND_PCM_APPEND)) {
16691668
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
1670-
if (SNDRV_PROTOCOL_VERSION(2, 0, 9) <= ver) {
1671-
struct timespec timespec;
1672-
if (clock_gettime(CLOCK_MONOTONIC, &timespec) == 0) {
1669+
if (SNDRV_PROTOCOL_VERSION(2, 0, 9) <= ver) {
1670+
struct timespec timespec;
1671+
if (clock_gettime(CLOCK_MONOTONIC, &timespec) == 0) {
1672+
if (!(mode & SND_PCM_APPEND)) {
16731673
int on = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
16741674
if (ioctl(fd, SNDRV_PCM_IOCTL_TTSTAMP, &on) < 0) {
16751675
ret = -errno;
16761676
SNDMSG("TTSTAMP failed");
16771677
return ret;
16781678
}
1679-
tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
16801679
}
1681-
} else
1680+
tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
1681+
}
1682+
} else
16821683
#endif
1683-
if (SNDRV_PROTOCOL_VERSION(2, 0, 5) <= ver) {
1684-
int on = 1;
1685-
if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) {
1686-
ret = -errno;
1687-
SNDMSG("TSTAMP failed");
1688-
return ret;
1689-
}
1684+
if (SNDRV_PROTOCOL_VERSION(2, 0, 5) <= ver && !(mode & SND_PCM_APPEND)) {
1685+
int on = 1;
1686+
if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) {
1687+
ret = -errno;
1688+
SNDMSG("TSTAMP failed");
1689+
return ret;
16901690
}
16911691
}
1692-
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
1693-
else {
1694-
/* the first stream already sets this */
1695-
tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
1696-
}
1697-
#endif
16981692

16991693
hw = calloc(1, sizeof(snd_pcm_hw_t));
17001694
if (!hw) {

0 commit comments

Comments
 (0)