All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH alsa-lib 0/5] Add monotonic raw timestamp support
@ 2014-07-10 13:09 Takashi Iwai
  2014-07-10 13:09 ` [PATCH alsa-lib 1/5] pcm: Provide a CLOCK_MONOTONIC_RAW timestamp type Takashi Iwai
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Takashi Iwai @ 2014-07-10 13:09 UTC (permalink / raw)
  To: alsa-devel; +Cc: Daniel Thompson, Mark Brown, Clemens Ladisch

Hi,

this is a series of patches to add the monotonic raw timestamp support
to alsa-lib.  A couple of new API functions and the new type are
introduced while the old hw_params monotonic function still remains.
Maybe we should mark it depecated?


Takashi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH alsa-lib 1/5] pcm: Provide a CLOCK_MONOTONIC_RAW timestamp type
  2014-07-10 13:09 [PATCH alsa-lib 0/5] Add monotonic raw timestamp support Takashi Iwai
@ 2014-07-10 13:09 ` Takashi Iwai
  2014-07-10 13:09 ` [PATCH alsa-lib 2/5] Add timestamp type to sw_params (internal only) Takashi Iwai
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2014-07-10 13:09 UTC (permalink / raw)
  To: alsa-devel; +Cc: Daniel Thompson, Mark Brown, Clemens Ladisch

From: Mark Brown <broonie@linaro.org>

For applications which need to synchronise with external timebases such
as broadcast TV applications the kernel monotonic time is not optimal as
it includes adjustments from NTP and so may still include discontinuities
due to that. A raw monotonic time which does not include any adjustments
is available in the kernel from getrawmonotonic() so provide userspace with
a new timestamp type SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW which provides
timestamps based on this as an option.

Reported-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/sound/asound.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/sound/asound.h b/include/sound/asound.h
index 1774a5c3ef10..9061cdd5b69f 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -457,7 +457,8 @@ struct snd_xfern {
 enum {
 	SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0,	/* gettimeofday equivalent */
 	SNDRV_PCM_TSTAMP_TYPE_MONOTONIC,	/* posix_clock_monotonic equivalent */
-	SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC,
+	SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW,	/* monotonic_raw (no NTP) */
+	SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW,
 };
 
 /* channel positions */
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH alsa-lib 2/5] Add timestamp type to sw_params (internal only)
  2014-07-10 13:09 [PATCH alsa-lib 0/5] Add monotonic raw timestamp support Takashi Iwai
  2014-07-10 13:09 ` [PATCH alsa-lib 1/5] pcm: Provide a CLOCK_MONOTONIC_RAW timestamp type Takashi Iwai
@ 2014-07-10 13:09 ` Takashi Iwai
  2014-07-10 13:09 ` [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type Takashi Iwai
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2014-07-10 13:09 UTC (permalink / raw)
  To: alsa-devel; +Cc: Daniel Thompson, Mark Brown, Clemens Ladisch

This patch is just the udpate of sound/asound.h taken from the kernel
commit.  The API changes and PCM structure changes will follow after
this.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/sound/asound.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/sound/asound.h b/include/sound/asound.h
index 9061cdd5b69f..552f41bd1ca9 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -136,7 +136,7 @@ struct snd_hwdep_dsp_image {
  *                                                                           *
  *****************************************************************************/
 
-#define SNDRV_PCM_VERSION		SNDRV_PROTOCOL_VERSION(2, 0, 11)
+#define SNDRV_PCM_VERSION		SNDRV_PROTOCOL_VERSION(2, 0, 12)
 
 typedef unsigned long snd_pcm_uframes_t;
 typedef signed long snd_pcm_sframes_t;
@@ -386,7 +386,9 @@ struct snd_pcm_sw_params {
 	snd_pcm_uframes_t silence_threshold;	/* min distance from noise for silence filling */
 	snd_pcm_uframes_t silence_size;		/* silence block size */
 	snd_pcm_uframes_t boundary;		/* pointers wrap point */
-	unsigned char reserved[64];		/* reserved for future */
+	unsigned int tstamp_type;		/* timestamp type */
+	int pads;				/* alignment, reserved */
+	unsigned char reserved[56];		/* reserved for future */
 };
 
 struct snd_pcm_channel_info {
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type
  2014-07-10 13:09 [PATCH alsa-lib 0/5] Add monotonic raw timestamp support Takashi Iwai
  2014-07-10 13:09 ` [PATCH alsa-lib 1/5] pcm: Provide a CLOCK_MONOTONIC_RAW timestamp type Takashi Iwai
  2014-07-10 13:09 ` [PATCH alsa-lib 2/5] Add timestamp type to sw_params (internal only) Takashi Iwai
@ 2014-07-10 13:09 ` Takashi Iwai
  2014-07-10 13:22   ` Clemens Ladisch
  2014-07-10 13:09 ` [PATCH alsa-lib 4/5] pcm: Implement timestamp type setup in hw plugin Takashi Iwai
  2014-07-10 13:09 ` [PATCH alsa-lib 5/5] pcm: Implement timestamp type handling in all plugins Takashi Iwai
  4 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2014-07-10 13:09 UTC (permalink / raw)
  To: alsa-devel; +Cc: Daniel Thompson, Mark Brown, Clemens Ladisch

For obtaining / changing the timestamp type, add the corresponding
sw_params accessor API functions together with the public definitions
of timestamp types.

This patch only adds the functions and defines but doesn't bring the
functional changes yet.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/pcm.h       |  9 +++++++++
 src/pcm/pcm.c       | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/pcm/pcm_local.h |  1 +
 3 files changed, 63 insertions(+)

diff --git a/include/pcm.h b/include/pcm.h
index 95b8aed6de2a..11e9f0dfba13 100644
--- a/include/pcm.h
+++ b/include/pcm.h
@@ -317,6 +317,13 @@ typedef enum _snd_pcm_tstamp {
 	SND_PCM_TSTAMP_LAST = SND_PCM_TSTAMP_ENABLE
 } snd_pcm_tstamp_t;
 
+typedef enum _snd_pcm_tstamp_type {
+	SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0,	/** gettimeofday equivalent */
+	SND_PCM_TSTAMP_TYPE_MONOTONIC,	/** posix_clock_monotonic equivalent */
+	SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW,	/** monotonic_raw (no NTP) */
+	SND_PCM_TSTAMP_TYPE_LAST = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW,
+} snd_pcm_tstamp_type_t;
+
 /** Unsigned frames quantity */
 typedef unsigned long snd_pcm_uframes_t;
 /** Signed frames quantity */
@@ -844,6 +851,8 @@ int snd_pcm_sw_params_get_boundary(const snd_pcm_sw_params_t *params, snd_pcm_uf
 
 int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val);
 int snd_pcm_sw_params_get_tstamp_mode(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_t *val);
+int snd_pcm_sw_params_set_tstamp_type(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t val);
+int snd_pcm_sw_params_get_tstamp_type(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t *val);
 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
 int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
 int snd_pcm_sw_params_set_period_event(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, int val);
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 7e46014627c2..1ec67fb405d7 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -1483,6 +1483,7 @@ int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsign
 #define XRUN(v) [SND_PCM_XRUN_##v] = #v
 #define SILENCE(v) [SND_PCM_SILENCE_##v] = #v
 #define TSTAMP(v) [SND_PCM_TSTAMP_##v] = #v
+#define TSTAMP_TYPE(v) [SND_PCM_TSTAMP_TYPE_##v] = #v
 #define ACCESS(v) [SND_PCM_ACCESS_##v] = #v
 #define START(v) [SND_PCM_START_##v] = #v
 #define HW_PARAM(v) [SND_PCM_HW_PARAM_##v] = #v
@@ -1680,6 +1681,12 @@ static const char *const snd_pcm_tstamp_mode_names[] = {
 	TSTAMP(NONE),
 	TSTAMP(ENABLE),
 };
+
+static const char *const snd_pcm_tstamp_type_names[] = {
+	TSTAMP_TYPE(GETTIMEOFDAY),
+	TSTAMP_TYPE(MONOTONIC),
+	TSTAMP_TYPE(MONOTONIC_RAW),
+};
 #endif
 
 /**
@@ -1826,6 +1833,18 @@ const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode)
 }
 
 /**
+ * \brief get name of PCM tstamp type setting
+ * \param mode PCM tstamp type
+ * \return ascii name of PCM tstamp type setting
+ */
+const char *snd_pcm_tstamp_type_name(snd_pcm_tstamp_t type)
+{
+	if (type > SND_PCM_TSTAMP_TYPE_LAST)
+		return NULL;
+	return snd_pcm_tstamp_type_names[type];
+}
+
+/**
  * \brief get name of PCM state
  * \param state PCM state
  * \return ascii name of PCM state
@@ -1899,6 +1918,7 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out)
 		return -EIO;
 	}
 	snd_output_printf(out, "  tstamp_mode  : %s\n", snd_pcm_tstamp_mode_name(pcm->tstamp_mode));
+	snd_output_printf(out, "  tstamp_type  : %s\n", snd_pcm_tstamp_type_name(pcm->tstamp_mode));
 	snd_output_printf(out, "  period_step  : %d\n", pcm->period_step);
 	snd_output_printf(out, "  avail_min    : %ld\n", pcm->avail_min);
 	snd_output_printf(out, "  period_event : %i\n", pcm->period_event);
@@ -5591,6 +5611,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
 		return -EIO;
 	}
 	params->tstamp_mode = pcm->tstamp_mode;
+	params->tstamp_type = pcm->tstamp_type;
 	params->period_step = pcm->period_step;
 	params->sleep_min = 0;
 	params->avail_min = pcm->avail_min;
@@ -5613,6 +5634,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
 int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out)
 {
 	snd_output_printf(out, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(params->tstamp_mode));
+	snd_output_printf(out, "tstamp_type: %s\n", snd_pcm_tstamp_type_name(params->tstamp_mode));
 	snd_output_printf(out, "period_step: %u\n", params->period_step);
 	snd_output_printf(out, "avail_min: %lu\n", params->avail_min);
 	snd_output_printf(out, "start_threshold: %ld\n", params->start_threshold);
@@ -5811,6 +5833,37 @@ int snd_pcm_sw_params_get_tstamp_mode(const snd_pcm_sw_params_t *params, snd_pcm
 }
 
 /**
+ * \brief Set timestamp type inside a software configuration container
+ * \param pcm PCM handle
+ * \param params Software configuration container
+ * \param val Timestamp type
+ * \return 0 otherwise a negative error code
+ */
+int snd_pcm_sw_params_set_tstamp_type(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t val)
+{
+	assert(pcm && params);
+	if (CHECK_SANITY(val > SND_PCM_TSTAMP_TYPE_LAST)) {
+		SNDMSG("invalid tstamp_type value %d", val);
+		return -EINVAL;
+	}
+	params->tstamp_type = val;
+	return 0;
+}
+
+/**
+ * \brief Get timestamp type from a software configuration container
+ * \param params Software configuration container
+ * \param val Returned timestamp type
+ * \return 0 otherwise a negative error code
+ */
+int snd_pcm_sw_params_get_tstamp_type(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t *val)
+{
+	assert(params && val);
+	*val = params->tstamp_type;
+	return 0;
+}
+
+/**
  * \brief (DEPRECATED) Set minimum number of ticks to sleep inside a software configuration container
  * \param pcm PCM handle
  * \param params Software configuration container
diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h
index 8a6c7431cc40..3ed7e1a88792 100644
--- a/src/pcm/pcm_local.h
+++ b/src/pcm/pcm_local.h
@@ -202,6 +202,7 @@ struct _snd_pcm {
 	unsigned int period_time;	/* period duration */
 	snd_interval_t periods;
 	snd_pcm_tstamp_t tstamp_mode;	/* timestamp mode */
+	snd_pcm_tstamp_type_t tstamp_type;	/* timestamp type */
 	unsigned int period_step;
 	snd_pcm_uframes_t avail_min;	/* min avail frames for wakeup */
 	int period_event;
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH alsa-lib 4/5] pcm: Implement timestamp type setup in hw plugin
  2014-07-10 13:09 [PATCH alsa-lib 0/5] Add monotonic raw timestamp support Takashi Iwai
                   ` (2 preceding siblings ...)
  2014-07-10 13:09 ` [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type Takashi Iwai
@ 2014-07-10 13:09 ` Takashi Iwai
  2014-07-10 13:09 ` [PATCH alsa-lib 5/5] pcm: Implement timestamp type handling in all plugins Takashi Iwai
  4 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2014-07-10 13:09 UTC (permalink / raw)
  To: alsa-devel; +Cc: Daniel Thompson, Mark Brown, Clemens Ladisch

This patch implements the support for sw_params timestamp type in PCM
hw layer.  As gettimestamp() is still unchanged, the resultant
timstamps may be still with CLOCK_MONOTONIC even if you pass monotonic
raw type.  More fixes will follow.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 src/pcm/pcm_hw.c | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index ed8319728130..bafa8debeb0b 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -304,7 +304,8 @@ static int snd_pcm_hw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
 
 	if (params->info != ~0U) {
 		params->info &= ~0xf0000000;
-		params->info |= (pcm->monotonic ? SND_PCM_INFO_MONOTONIC : 0);
+		if (pcm->tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY)
+			params->info |= SND_PCM_INFO_MONOTONIC;
 	}
 	
 	return 0;
@@ -328,7 +329,8 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
 		return err;
 	}
 	params->info &= ~0xf0000000;
-	params->info |= (pcm->monotonic ? SND_PCM_INFO_MONOTONIC : 0);
+	if (pcm->tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY)
+		params->info |= SND_PCM_INFO_MONOTONIC;
 	err = sync_ptr(hw, 0);
 	if (err < 0)
 		return err;
@@ -435,6 +437,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
 	int old_period_event = sw_get_period_event(params);
 	sw_set_period_event(params, 0);
 	if ((snd_pcm_tstamp_t) params->tstamp_mode == pcm->tstamp_mode &&
+	    (snd_pcm_tstamp_type_t) params->tstamp_type == pcm->tstamp_type &&
 	    params->period_step == pcm->period_step &&
 	    params->start_threshold == pcm->start_threshold &&
 	    params->stop_threshold == pcm->stop_threshold &&
@@ -444,11 +447,33 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
 		hw->mmap_control->avail_min = params->avail_min;
 		return sync_ptr(hw, 0);
 	}
+	if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW &&
+	    hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 12)) {
+		SYSMSG("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW");
+		return -EINVAL;
+	}
+	if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC &&
+	    hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 5)) {
+		SYSMSG("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC");
+		return -EINVAL;
+	}
 	if (ioctl(fd, SNDRV_PCM_IOCTL_SW_PARAMS, params) < 0) {
 		err = -errno;
 		SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
 		return err;
 	}
+	if ((snd_pcm_tstamp_type_t) params->tstamp_type != pcm->tstamp_type) {
+		if (hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 12)) {
+			int on = (snd_pcm_tstamp_type_t) params->tstamp_type ==
+				SND_PCM_TSTAMP_TYPE_MONOTONIC;
+			if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) {
+				err = -errno;
+				SNDMSG("TSTAMP failed\n");
+				return err;
+			}
+		}
+		pcm->tstamp_type = params->tstamp_type;
+	}
 	sw_set_period_event(params, old_period_event);
 	hw->mmap_control->avail_min = params->avail_min;
 	if (hw->period_event != old_period_event) {
@@ -1381,7 +1406,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
 		       int fd, int mmap_emulation ATTRIBUTE_UNUSED,
 		       int sync_ptr_ioctl)
 {
-	int ver, mode, monotonic = 0;
+	int ver, mode;
+	snd_pcm_tstamp_type_t tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
 	long fmode;
 	snd_pcm_t *pcm = NULL;
 	snd_pcm_hw_t *hw = NULL;
@@ -1429,7 +1455,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
 				SNDMSG("TTSTAMP failed\n");
 				return ret;
 			}
-			monotonic = 1;
+			tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
 		}
 	} else
 #endif
@@ -1471,7 +1497,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
 	pcm->private_data = hw;
 	pcm->poll_fd = fd;
 	pcm->poll_events = info.stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
-	pcm->monotonic = monotonic;
+	pcm->tstamp_type = tstamp_type;
+	pcm->monotonic = tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
 
 	ret = snd_pcm_hw_mmap_status(pcm);
 	if (ret < 0) {
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH alsa-lib 5/5] pcm: Implement timestamp type handling in all plugins
  2014-07-10 13:09 [PATCH alsa-lib 0/5] Add monotonic raw timestamp support Takashi Iwai
                   ` (3 preceding siblings ...)
  2014-07-10 13:09 ` [PATCH alsa-lib 4/5] pcm: Implement timestamp type setup in hw plugin Takashi Iwai
@ 2014-07-10 13:09 ` Takashi Iwai
  4 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2014-07-10 13:09 UTC (permalink / raw)
  To: alsa-devel; +Cc: Daniel Thompson, Mark Brown, Clemens Ladisch

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>
---
 src/pcm/pcm_adpcm.c     |  2 +-
 src/pcm/pcm_alaw.c      |  2 +-
 src/pcm/pcm_copy.c      |  2 +-
 src/pcm/pcm_direct.c    |  4 ++--
 src/pcm/pcm_direct.h    |  2 +-
 src/pcm/pcm_dmix.c      |  8 ++++----
 src/pcm/pcm_dshare.c    |  8 ++++----
 src/pcm/pcm_dsnoop.c    |  4 ++--
 src/pcm/pcm_file.c      |  6 +++---
 src/pcm/pcm_generic.c   |  2 +-
 src/pcm/pcm_hooks.c     |  2 +-
 src/pcm/pcm_hw.c        |  1 -
 src/pcm/pcm_iec958.c    |  2 +-
 src/pcm/pcm_ioplug.c    |  9 ++++++---
 src/pcm/pcm_ladspa.c    |  2 +-
 src/pcm/pcm_lfloat.c    |  2 +-
 src/pcm/pcm_linear.c    |  2 +-
 src/pcm/pcm_local.h     | 45 +++++++++++++++++++++++++++++----------------
 src/pcm/pcm_meter.c     |  2 +-
 src/pcm/pcm_mmap_emul.c |  2 +-
 src/pcm/pcm_mulaw.c     |  2 +-
 src/pcm/pcm_multi.c     |  2 +-
 src/pcm/pcm_null.c      |  2 +-
 src/pcm/pcm_plug.c      |  2 +-
 src/pcm/pcm_rate.c      |  4 ++--
 src/pcm/pcm_route.c     |  2 +-
 src/pcm/pcm_share.c     |  6 +++---
 src/pcm/pcm_softvol.c   |  2 +-
 28 files changed, 73 insertions(+), 58 deletions(-)

diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c
index 6f0e7c4cc631..1a83c5a0e21c 100644
--- a/src/pcm/pcm_adpcm.c
+++ b/src/pcm/pcm_adpcm.c
@@ -579,7 +579,7 @@ int snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfor
 	pcm->private_data = adpcm;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &adpcm->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &adpcm->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c
index 1b1bab83c944..db759e3effa4 100644
--- a/src/pcm/pcm_alaw.c
+++ b/src/pcm/pcm_alaw.c
@@ -453,7 +453,7 @@ int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sform
 	pcm->private_data = alaw;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &alaw->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &alaw->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_copy.c b/src/pcm/pcm_copy.c
index 56a1f6bcc912..66d3a4719856 100644
--- a/src/pcm/pcm_copy.c
+++ b/src/pcm/pcm_copy.c
@@ -209,7 +209,7 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int
 	pcm->private_data = copy;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &copy->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &copy->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
index 5416cf71674c..8e37bcba5e19 100644
--- a/src/pcm/pcm_direct.c
+++ b/src/pcm/pcm_direct.c
@@ -840,6 +840,7 @@ static void save_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)
 	COPY_SLAVE(period_time);
 	COPY_SLAVE(periods);
 	COPY_SLAVE(tstamp_mode);
+	COPY_SLAVE(tstamp_type);
 	COPY_SLAVE(period_step);
 	COPY_SLAVE(avail_min);
 	COPY_SLAVE(start_threshold);
@@ -857,7 +858,6 @@ static void save_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)
 	COPY_SLAVE(buffer_time);
 	COPY_SLAVE(sample_bits);
 	COPY_SLAVE(frame_bits);
-	COPY_SLAVE(monotonic);
 }
 
 #undef COPY_SLAVE
@@ -1204,6 +1204,7 @@ static void copy_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)
 	COPY_SLAVE(period_time);
 	COPY_SLAVE(periods);
 	COPY_SLAVE(tstamp_mode);
+	COPY_SLAVE(tstamp_type);
 	COPY_SLAVE(period_step);
 	COPY_SLAVE(avail_min);
 	COPY_SLAVE(start_threshold);
@@ -1221,7 +1222,6 @@ static void copy_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)
 	COPY_SLAVE(buffer_time);
 	COPY_SLAVE(sample_bits);
 	COPY_SLAVE(frame_bits);
-	COPY_SLAVE(monotonic);
 
 	spcm->info &= ~SND_PCM_INFO_PAUSE;
 	spcm->boundary = recalc_boundary_size(dmix->shmptr->s.boundary, spcm->buffer_size);
diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h
index 5ae39c0e4237..9b1ddbcf424a 100644
--- a/src/pcm/pcm_direct.h
+++ b/src/pcm/pcm_direct.h
@@ -85,8 +85,8 @@ typedef struct {
 		unsigned int period_size;
 		unsigned int period_time;
 		snd_interval_t periods;
-		unsigned int monotonic;
 		snd_pcm_tstamp_t tstamp_mode;
+		snd_pcm_tstamp_type_t tstamp_type;
 		unsigned int period_step;
 		unsigned int sleep_min; /* not used */
 		unsigned int avail_min;
diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
index 4aa6d4eab4a2..7c535093ea0f 100644
--- a/src/pcm/pcm_dmix.c
+++ b/src/pcm/pcm_dmix.c
@@ -428,7 +428,7 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
 		dmix->avail_max = avail;
 	if (avail >= pcm->stop_threshold) {
 		snd_timer_stop(dmix->timer);
-		gettimestamp(&dmix->trigger_tstamp, pcm->monotonic);
+		gettimestamp(&dmix->trigger_tstamp, pcm->tstamp_type);
 		if (dmix->state == SND_PCM_STATE_RUNNING) {
 			dmix->state = SND_PCM_STATE_XRUN;
 			return -EPIPE;
@@ -477,7 +477,7 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
 	memset(status, 0, sizeof(*status));
 	status->state = snd_pcm_dmix_state(pcm);
 	status->trigger_tstamp = dmix->trigger_tstamp;
-	gettimestamp(&status->tstamp, pcm->monotonic);
+	gettimestamp(&status->tstamp, pcm->tstamp_type);
 	status->avail = snd_pcm_mmap_playback_avail(pcm);
 	status->avail_max = status->avail > dmix->avail_max ? status->avail : dmix->avail_max;
 	dmix->avail_max = 0;
@@ -596,7 +596,7 @@ static int snd_pcm_dmix_start(snd_pcm_t *pcm)
 			return err;
 		snd_pcm_dmix_sync_area(pcm);
 	}
-	gettimestamp(&dmix->trigger_tstamp, pcm->monotonic);
+	gettimestamp(&dmix->trigger_tstamp, pcm->tstamp_type);
 	return 0;
 }
 
@@ -1104,7 +1104,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
 		
 	pcm->poll_fd = dmix->poll_fd;
 	pcm->poll_events = POLLIN;	/* it's different than other plugins */
-	pcm->monotonic = spcm->monotonic;
+	pcm->tstamp_type = spcm->tstamp_type;
 	pcm->mmap_rw = 1;
 	snd_pcm_set_hw_ptr(pcm, &dmix->hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &dmix->appl_ptr, -1, 0);
diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c
index f2d1103a6bfb..b985172825e7 100644
--- a/src/pcm/pcm_dshare.c
+++ b/src/pcm/pcm_dshare.c
@@ -195,7 +195,7 @@ static int snd_pcm_dshare_sync_ptr(snd_pcm_t *pcm)
 		dshare->avail_max = avail;
 	if (avail >= pcm->stop_threshold) {
 		snd_timer_stop(dshare->timer);
-		gettimestamp(&dshare->trigger_tstamp, pcm->monotonic);
+		gettimestamp(&dshare->trigger_tstamp, pcm->tstamp_type);
 		if (dshare->state == SND_PCM_STATE_RUNNING) {
 			dshare->state = SND_PCM_STATE_XRUN;
 			return -EPIPE;
@@ -226,7 +226,7 @@ static int snd_pcm_dshare_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
 	memset(status, 0, sizeof(*status));
 	status->state = snd_pcm_state(dshare->spcm);
 	status->trigger_tstamp = dshare->trigger_tstamp;
-	gettimestamp(&status->tstamp, pcm->monotonic);
+	gettimestamp(&status->tstamp, pcm->tstamp_type);
 	status->avail = snd_pcm_mmap_playback_avail(pcm);
 	status->avail_max = status->avail > dshare->avail_max ? status->avail : dshare->avail_max;
 	dshare->avail_max = 0;
@@ -346,7 +346,7 @@ static int snd_pcm_dshare_start(snd_pcm_t *pcm)
 			return err;
 		snd_pcm_dshare_sync_area(pcm);
 	}
-	gettimestamp(&dshare->trigger_tstamp, pcm->monotonic);
+	gettimestamp(&dshare->trigger_tstamp, pcm->tstamp_type);
 	return 0;
 }
 
@@ -792,7 +792,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
 
 	pcm->poll_fd = dshare->poll_fd;
 	pcm->poll_events = POLLIN;	/* it's different than other plugins */
-	pcm->monotonic = spcm->monotonic;
+	pcm->tstamp_type = spcm->tstamp_type;
 	pcm->mmap_rw = 1;
 	snd_pcm_set_hw_ptr(pcm, &dshare->hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &dshare->appl_ptr, -1, 0);
diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c
index 76379140c133..0f9c9df481bc 100644
--- a/src/pcm/pcm_dsnoop.c
+++ b/src/pcm/pcm_dsnoop.c
@@ -159,7 +159,7 @@ static int snd_pcm_dsnoop_sync_ptr(snd_pcm_t *pcm)
 	if (pcm->stop_threshold >= pcm->boundary)	/* don't care */
 		return 0;
 	if ((avail = snd_pcm_mmap_capture_hw_avail(pcm)) >= pcm->stop_threshold) {
-		gettimestamp(&dsnoop->trigger_tstamp, pcm->monotonic);
+		gettimestamp(&dsnoop->trigger_tstamp, pcm->tstamp_type);
 		dsnoop->state = SND_PCM_STATE_XRUN;
 		dsnoop->avail_max = avail;
 		return -EPIPE;
@@ -690,7 +690,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
 
 	pcm->poll_fd = dsnoop->poll_fd;
 	pcm->poll_events = POLLIN;	/* it's different than other plugins */
-	pcm->monotonic = spcm->monotonic;
+	pcm->tstamp_type = spcm->tstamp_type;
 	pcm->mmap_rw = 1;
 	snd_pcm_set_hw_ptr(pcm, &dsnoop->hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &dsnoop->appl_ptr, -1, 0);
diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
index b139f7f24dc3..a0b8bf41bf5b 100644
--- a/src/pcm/pcm_file.c
+++ b/src/pcm/pcm_file.c
@@ -781,10 +781,10 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
 	pcm->mmap_shadow = 1;
+	pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
-	pcm->monotonic = clock_gettime(CLOCK_MONOTONIC, &timespec) == 0;
-#else
-	pcm->monotonic = 0;
+	if (clock_gettime(CLOCK_MONOTONIC, &timespec) == 0)
+		pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
 #endif
 	pcm->stream = stream;
 	snd_pcm_link_hw_ptr(pcm, slave);
diff --git a/src/pcm/pcm_generic.c b/src/pcm/pcm_generic.c
index f068ee2585bc..9b605911f868 100644
--- a/src/pcm/pcm_generic.c
+++ b/src/pcm/pcm_generic.c
@@ -294,7 +294,7 @@ int snd_pcm_generic_real_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail,
 		if (ok && (snd_pcm_uframes_t)avail1 == *avail)
 			break;
 		*avail = avail1;
-		gettimestamp(tstamp, pcm->monotonic);
+		gettimestamp(tstamp, pcm->tstamp_type);
 		ok = 1;
 	}
 	return 0;
diff --git a/src/pcm/pcm_hooks.c b/src/pcm/pcm_hooks.c
index f83728245ecd..0b93c641daaa 100644
--- a/src/pcm/pcm_hooks.c
+++ b/src/pcm/pcm_hooks.c
@@ -240,7 +240,7 @@ int snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
 	pcm->mmap_shadow = 1;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_link_hw_ptr(pcm, slave);
 	snd_pcm_link_appl_ptr(pcm, slave);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index bafa8debeb0b..74cff672a0c1 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -1498,7 +1498,6 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
 	pcm->poll_fd = fd;
 	pcm->poll_events = info.stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
 	pcm->tstamp_type = tstamp_type;
-	pcm->monotonic = tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
 
 	ret = snd_pcm_hw_mmap_status(pcm);
 	if (ret < 0) {
diff --git a/src/pcm/pcm_iec958.c b/src/pcm/pcm_iec958.c
index 0c61fc17995b..38c4ce7e2421 100644
--- a/src/pcm/pcm_iec958.c
+++ b/src/pcm/pcm_iec958.c
@@ -534,7 +534,7 @@ int snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo
 	pcm->private_data = iec;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &iec->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &iec->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c
index c1c3a9835d47..85a88911eafc 100644
--- a/src/pcm/pcm_ioplug.c
+++ b/src/pcm/pcm_ioplug.c
@@ -448,7 +448,7 @@ static int snd_pcm_ioplug_start(snd_pcm_t *pcm)
 	if (err < 0)
 		return err;
 
-	gettimestamp(&io->trigger_tstamp, pcm->monotonic);
+	gettimestamp(&io->trigger_tstamp, pcm->tstamp_type);
 	io->data->state = SND_PCM_STATE_RUNNING;
 
 	return 0;
@@ -463,7 +463,7 @@ static int snd_pcm_ioplug_drop(snd_pcm_t *pcm)
 
 	io->data->callback->stop(io->data);
 
-	gettimestamp(&io->trigger_tstamp, pcm->monotonic);
+	gettimestamp(&io->trigger_tstamp, pcm->tstamp_type);
 	io->data->state = SND_PCM_STATE_SETUP;
 
 	return 0;
@@ -1069,7 +1069,10 @@ int snd_pcm_ioplug_reinit_status(snd_pcm_ioplug_t *ioplug)
 {
 	ioplug->pcm->poll_fd = ioplug->poll_fd;
 	ioplug->pcm->poll_events = ioplug->poll_events;
-	ioplug->pcm->monotonic = (ioplug->flags & SND_PCM_IOPLUG_FLAG_MONOTONIC) != 0;
+	if (ioplug->flags & SND_PCM_IOPLUG_FLAG_MONOTONIC)
+		ioplug->pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
+	else
+		ioplug->pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
 	ioplug->pcm->mmap_rw = ioplug->mmap_rw;
 	return 0;
 }
diff --git a/src/pcm/pcm_ladspa.c b/src/pcm/pcm_ladspa.c
index 7d1e3df878b0..631ee0f35b73 100644
--- a/src/pcm/pcm_ladspa.c
+++ b/src/pcm/pcm_ladspa.c
@@ -1641,7 +1641,7 @@ int snd_pcm_ladspa_open(snd_pcm_t **pcmp, const char *name,
 	pcm->private_data = ladspa;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &ladspa->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &ladspa->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_lfloat.c b/src/pcm/pcm_lfloat.c
index bbf72c274222..324282f0b7fc 100644
--- a/src/pcm/pcm_lfloat.c
+++ b/src/pcm/pcm_lfloat.c
@@ -412,7 +412,7 @@ int snd_pcm_lfloat_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo
 	pcm->private_data = lfloat;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &lfloat->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &lfloat->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c
index 7aa894185444..3d5bbb8a3688 100644
--- a/src/pcm/pcm_linear.c
+++ b/src/pcm/pcm_linear.c
@@ -484,7 +484,7 @@ int snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo
 	pcm->private_data = linear;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &linear->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &linear->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h
index 3ed7e1a88792..2206afe2c4a9 100644
--- a/src/pcm/pcm_local.h
+++ b/src/pcm/pcm_local.h
@@ -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;
+	}
+	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);
diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c
index 676fbef89c30..034f582564a8 100644
--- a/src/pcm/pcm_meter.c
+++ b/src/pcm/pcm_meter.c
@@ -591,7 +591,7 @@ int snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, unsigned int frequenc
 	pcm->private_data = meter;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_link_hw_ptr(pcm, slave);
 	snd_pcm_link_appl_ptr(pcm, slave);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_mmap_emul.c b/src/pcm/pcm_mmap_emul.c
index 63789bc07c1b..b2b15efd07d9 100644
--- a/src/pcm/pcm_mmap_emul.c
+++ b/src/pcm/pcm_mmap_emul.c
@@ -428,7 +428,7 @@ int __snd_pcm_mmap_emul_open(snd_pcm_t **pcmp, const char *name,
 	pcm->private_data = map;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &map->hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &map->appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c
index 7adce38e9f48..011b2a516be0 100644
--- a/src/pcm/pcm_mulaw.c
+++ b/src/pcm/pcm_mulaw.c
@@ -467,7 +467,7 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfor
 	pcm->private_data = mulaw;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &mulaw->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &mulaw->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c
index a84e0ce48c59..4b8299ed6bcd 100644
--- a/src/pcm/pcm_multi.c
+++ b/src/pcm/pcm_multi.c
@@ -1077,7 +1077,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
 	pcm->private_data = multi;
 	pcm->poll_fd = multi->slaves[master_slave].pcm->poll_fd;
 	pcm->poll_events = multi->slaves[master_slave].pcm->poll_events;
-	pcm->monotonic = multi->slaves[master_slave].pcm->monotonic;
+	pcm->tstamp_type = multi->slaves[master_slave].pcm->tstamp_type;
 	snd_pcm_link_hw_ptr(pcm, multi->slaves[master_slave].pcm);
 	snd_pcm_link_appl_ptr(pcm, multi->slaves[master_slave].pcm);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c
index 655261f74e1f..f11a1020f7e3 100644
--- a/src/pcm/pcm_null.c
+++ b/src/pcm/pcm_null.c
@@ -100,7 +100,7 @@ static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
 	memset(status, 0, sizeof(*status));
 	status->state = null->state;
 	status->trigger_tstamp = null->trigger_tstamp;
-	gettimestamp(&status->tstamp, pcm->monotonic);
+	gettimestamp(&status->tstamp, pcm->tstamp_type);
 	status->avail = snd_pcm_null_avail_update(pcm);
 	status->avail_max = pcm->buffer_size;
 	return 0;
diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c
index 7a6c2b99c639..5639b9ea8044 100644
--- a/src/pcm/pcm_plug.c
+++ b/src/pcm/pcm_plug.c
@@ -1127,7 +1127,7 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp,
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
 	pcm->mmap_shadow = 1;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_link_hw_ptr(pcm, slave);
 	snd_pcm_link_appl_ptr(pcm, slave);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
index 7f667d4c6a52..aea95e52d3dc 100644
--- a/src/pcm/pcm_rate.c
+++ b/src/pcm/pcm_rate.c
@@ -1067,7 +1067,7 @@ static int snd_pcm_rate_start(snd_pcm_t *pcm)
 	if (snd_pcm_state(rate->gen.slave) != SND_PCM_STATE_PREPARED)
 		return -EBADFD;
 
-	gettimestamp(&rate->trigger_tstamp, pcm->monotonic);
+	gettimestamp(&rate->trigger_tstamp, pcm->tstamp_type);
 
 	avail = snd_pcm_mmap_playback_hw_avail(rate->gen.slave);
 	if (avail == 0) {
@@ -1370,7 +1370,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
 	pcm->mmap_rw = 1;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &rate->hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &rate->appl_ptr, -1, 0);
 	*pcmp = pcm;
diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
index 751e36f28fdf..2f0be38b1906 100644
--- a/src/pcm/pcm_route.c
+++ b/src/pcm/pcm_route.c
@@ -1122,7 +1122,7 @@ int snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
 	pcm->private_data = route;
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &route->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &route->plug.appl_ptr, -1, 0);
 	err = route_load_ttable(&route->params, pcm->stream, tt_ssize, ttable, tt_cused, tt_sused);
diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c
index 118ab2617780..97705447dd6d 100644
--- a/src/pcm/pcm_share.c
+++ b/src/pcm/pcm_share.c
@@ -971,7 +971,7 @@ static int snd_pcm_share_start(snd_pcm_t *pcm)
 	}
 	slave->running_count++;
 	_snd_pcm_share_update(pcm);
-	gettimestamp(&share->trigger_tstamp, pcm->monotonic);
+	gettimestamp(&share->trigger_tstamp, pcm->tstamp_type);
  _end:
 	Pthread_mutex_unlock(&slave->mutex);
 	return err;
@@ -1126,7 +1126,7 @@ static void _snd_pcm_share_stop(snd_pcm_t *pcm, snd_pcm_state_t state)
 		return;
 	}
 #endif
-	gettimestamp(&share->trigger_tstamp, pcm->monotonic);
+	gettimestamp(&share->trigger_tstamp, pcm->tstamp_type);
 	if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
 		snd_pcm_areas_copy(pcm->stopped_areas, 0,
 				   pcm->running_areas, 0,
@@ -1526,7 +1526,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname,
 	pcm->private_data = share;
 	pcm->poll_fd = share->client_socket;
 	pcm->poll_events = stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
-	pcm->monotonic = slave->pcm->monotonic;
+	pcm->tstamp_type = slave->pcm->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &share->hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &share->appl_ptr, -1, 0);
 
diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c
index 5da92049cc88..c6cfd8896b26 100644
--- a/src/pcm/pcm_softvol.c
+++ b/src/pcm/pcm_softvol.c
@@ -903,7 +903,7 @@ int snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name,
 	 * an extra buffer.
 	 */
 	pcm->mmap_shadow = 1;
-	pcm->monotonic = slave->monotonic;
+	pcm->tstamp_type = slave->tstamp_type;
 	snd_pcm_set_hw_ptr(pcm, &svol->plug.hw_ptr, -1, 0);
 	snd_pcm_set_appl_ptr(pcm, &svol->plug.appl_ptr, -1, 0);
 	*pcmp = pcm;
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type
  2014-07-10 13:09 ` [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type Takashi Iwai
@ 2014-07-10 13:22   ` Clemens Ladisch
  2014-07-10 13:25     ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Clemens Ladisch @ 2014-07-10 13:22 UTC (permalink / raw)
  To: Takashi Iwai, alsa-devel; +Cc: Daniel Thompson, Mark Brown

Takashi Iwai wrote:
> @@ -1899,6 +1918,7 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out)
>  		return -EIO;
>  	}
>  	snd_output_printf(out, "  tstamp_mode  : %s\n", snd_pcm_tstamp_mode_name(pcm->tstamp_mode));
> +	snd_output_printf(out, "  tstamp_type  : %s\n", snd_pcm_tstamp_type_name(pcm->tstamp_mode));

> @@ -5613,6 +5634,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
>  int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out)
>  {
>  	snd_output_printf(out, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(params->tstamp_mode));
> +	snd_output_printf(out, "tstamp_type: %s\n", snd_pcm_tstamp_type_name(params->tstamp_mode));

_type, not _mode


Regards,
Clemens

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type
  2014-07-10 13:22   ` Clemens Ladisch
@ 2014-07-10 13:25     ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2014-07-10 13:25 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel, Mark Brown, Daniel Thompson

At Thu, 10 Jul 2014 15:22:06 +0200,
Clemens Ladisch wrote:
> 
> Takashi Iwai wrote:
> > @@ -1899,6 +1918,7 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out)
> >  		return -EIO;
> >  	}
> >  	snd_output_printf(out, "  tstamp_mode  : %s\n", snd_pcm_tstamp_mode_name(pcm->tstamp_mode));
> > +	snd_output_printf(out, "  tstamp_type  : %s\n", snd_pcm_tstamp_type_name(pcm->tstamp_mode));
> 
> > @@ -5613,6 +5634,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
> >  int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out)
> >  {
> >  	snd_output_printf(out, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(params->tstamp_mode));
> > +	snd_output_printf(out, "tstamp_type: %s\n", snd_pcm_tstamp_type_name(params->tstamp_mode));
> 
> _type, not _mode

Thanks, fixed.


Takashi

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-07-10 13:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-10 13:09 [PATCH alsa-lib 0/5] Add monotonic raw timestamp support Takashi Iwai
2014-07-10 13:09 ` [PATCH alsa-lib 1/5] pcm: Provide a CLOCK_MONOTONIC_RAW timestamp type Takashi Iwai
2014-07-10 13:09 ` [PATCH alsa-lib 2/5] Add timestamp type to sw_params (internal only) Takashi Iwai
2014-07-10 13:09 ` [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type Takashi Iwai
2014-07-10 13:22   ` Clemens Ladisch
2014-07-10 13:25     ` Takashi Iwai
2014-07-10 13:09 ` [PATCH alsa-lib 4/5] pcm: Implement timestamp type setup in hw plugin Takashi Iwai
2014-07-10 13:09 ` [PATCH alsa-lib 5/5] pcm: Implement timestamp type handling in all plugins Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.