]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: hw: do not reset tstamp_type in SND_PCM_APPEND mode
authorKevin Groeneveld <kgroeneveld@lenbrook.com>
Fri, 4 Apr 2025 19:59:59 +0000 (15:59 -0400)
committerJaroslav Kysela <perex@perex.cz>
Mon, 7 Apr 2025 16:49:52 +0000 (18:49 +0200)
When the first client of plugins such as dshare open the hw device they set
a default tstamp_type in snd_pcm_direct_initialize_slave based on
tstamp_type from the config file. But when subsequent clients open the same
plugin the snd_pcm_hw_open_fd function clobbers this default.

Closes: https://github.com/alsa-project/alsa-lib/pull/450
Signed-off-by: Kevin Groeneveld <kgroeneveld@lenbrook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_hw.c

index f3fbcb6e842276c14143776068d822e04ea4b423..c99b186aa010797155f74861de05f2918a7d2af0 100644 (file)
@@ -1665,26 +1665,28 @@ 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) {
-                       int on = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
-                       if (ioctl(fd, SNDRV_PCM_IOCTL_TTSTAMP, &on) < 0) {
+               if (SNDRV_PROTOCOL_VERSION(2, 0, 9) <= ver) {
+                       struct timespec timespec;
+                       if (clock_gettime(CLOCK_MONOTONIC, &timespec) == 0) {
+                               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) {
+                       int on = 1;
+                       if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) {
                                ret = -errno;
-                               SNDMSG("TTSTAMP failed");
+                               SNDMSG("TSTAMP failed");
                                return ret;
                        }
-                       tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
-               }
-       } else
-#endif
-         if (SNDRV_PROTOCOL_VERSION(2, 0, 5) <= ver) {
-               int on = 1;
-               if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) {
-                       ret = -errno;
-                       SNDMSG("TSTAMP failed");
-                       return ret;
                }
        }