alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH v2 02/10] ALSA: core: allow for trigger_tstamp snapshot in .trigger
Date: Fri, 19 Dec 2014 11:25:05 -0600	[thread overview]
Message-ID: <1419009913-3686-3-git-send-email-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <1419009913-3686-1-git-send-email-pierre-louis.bossart@linux.intel.com>

Don't use generic snapshot of trigger_tstamp if low-level driver or
hardware can get a more precise value for better audio/system time
synchronization.

Also add definitions for delayed updates if actual trigger tstamp
can be only be provided after a delay due to hardware constraints.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 include/sound/pcm.h     | 2 ++
 sound/core/pcm_native.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 1e7f74a..2641d86 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -281,6 +281,8 @@ struct snd_pcm_runtime {
 	/* -- Status -- */
 	struct snd_pcm_substream *trigger_master;
 	struct timespec trigger_tstamp;	/* trigger timestamp */
+	bool trigger_tstamp_latched;     /* trigger timestamp latched in low-level driver/hardware */
+	bool trigger_tstamp_pending_update; /* trigger timestamp being updated from initial estimate */
 	int overrange;
 	snd_pcm_uframes_t avail_max;
 	snd_pcm_uframes_t hw_ptr_base;	/* Position at buffer restart */
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 5dc83fb..ae2a93a 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -809,7 +809,8 @@ static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream)
 	if (runtime->trigger_master == NULL)
 		return;
 	if (runtime->trigger_master == substream) {
-		snd_pcm_gettime(runtime, &runtime->trigger_tstamp);
+		if (runtime->trigger_tstamp_latched == 0)
+			snd_pcm_gettime(runtime, &runtime->trigger_tstamp);
 	} else {
 		snd_pcm_trigger_tstamp(runtime->trigger_master);
 		runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp;
@@ -978,6 +979,7 @@ static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state)
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
 	    !snd_pcm_playback_data(substream))
 		return -EPIPE;
+	runtime->trigger_tstamp_latched = 0;
 	runtime->trigger_master = substream;
 	return 0;
 }
-- 
1.9.1

  parent reply	other threads:[~2014-12-19 17:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-19 17:25 [PATCH v2 00/10] audio timestamping evolutions Pierre-Louis Bossart
2014-12-19 17:25 ` [PATCH v2 01/10] ALSA: core: don't override timestamp unconditionally Pierre-Louis Bossart
2014-12-19 17:25 ` Pierre-Louis Bossart [this message]
2014-12-19 17:25 ` [PATCH v2 03/10] ALSA: hda: read trigger_timestamp immediately after starting DMA Pierre-Louis Bossart
2014-12-19 17:25 ` [PATCH v2 04/10] ALSA: usb: update trigger timestamp on first non-zero URB submitted Pierre-Louis Bossart
2014-12-19 17:25 ` [PATCH v2 05/10] ALSA: core: add info_ext field in hw_params and pcm_hardware Pierre-Louis Bossart
2014-12-19 17:25 ` [PATCH v2 06/10] ALSA: core: selection of audio_tstamp type and accuracy reports Pierre-Louis Bossart
2014-12-19 17:25 ` [PATCH v2 07/10] ALSA: core: pass audio tstamp config from userspace Pierre-Louis Bossart
2014-12-19 17:25 ` [PATCH v2 08/10] ALSA: core: pass audio tstamp config from userspace in compat mode Pierre-Louis Bossart
2014-12-19 17:25 ` [PATCH v2 09/10] ALSA: core: replace .wall_clock by .get_time_info Pierre-Louis Bossart
2014-12-19 17:25 ` [PATCH v2 10/10] ALSA: hda: replace .wallclock " Pierre-Louis Bossart
2014-12-20  6:07   ` Raymond Yau
2014-12-20 17:50     ` Pierre-Louis Bossart
2014-12-19 20:38 ` [PATCH v2 00/10] audio timestamping evolutions Jaroslav Kysela
2014-12-19 21:17   ` Pierre-Louis Bossart
2014-12-21 13:14     ` Jaroslav Kysela
2014-12-26 11:12       ` Takashi Iwai
2015-01-05 21:11       ` Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1419009913-3686-3-git-send-email-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).