All of lore.kernel.org
 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 v4 04/10] ALSA: usb: update trigger timestamp on first non-zero URB submitted
Date: Fri, 30 Jan 2015 17:55:57 -0600	[thread overview]
Message-ID: <1422662163-7391-5-git-send-email-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <1422662163-7391-1-git-send-email-pierre-louis.bossart@linux.intel.com>

The first URBs are submitted during the prepare stage. When .trigger is
called, the ALSA core saves a trigger tstamp that doesn't correspond to
the actual time when the samples are submitted. The trigger_tstamp is
now updated when the first data are submitted to avoid any time offsets.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/usb/pcm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 0d8aba5..7c36fc1 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -1464,6 +1464,14 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
 	subs->last_frame_number = usb_get_current_frame_number(subs->dev);
 	subs->last_frame_number &= 0xFF; /* keep 8 LSBs */
 
+	if (runtime->trigger_tstamp_pending_update == 1) {
+		/* this is the first actual URB submitted,
+		 * update trigger timestamp to reflect actual start time
+		 */
+		snd_pcm_gettime(runtime, &runtime->trigger_tstamp);
+		runtime->trigger_tstamp_pending_update = 0;
+	}
+
 	spin_unlock_irqrestore(&subs->lock, flags);
 	urb->transfer_buffer_length = bytes;
 	if (period_elapsed)
@@ -1550,6 +1558,7 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
+		substream->runtime->trigger_tstamp_pending_update = 1;
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
 		subs->data_endpoint->prepare_data_urb = prepare_playback_urb;
 		subs->data_endpoint->retire_data_urb = retire_playback_urb;
-- 
1.9.1

  parent reply	other threads:[~2015-01-30 23:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30 23:55 [PATCH v4 00/10] audio timestamping evolutions Pierre-Louis Bossart
2015-01-30 23:55 ` [PATCH v4 01/10] ALSA: core: don't override timestamp unconditionally Pierre-Louis Bossart
2015-01-30 23:55 ` [PATCH v4 02/10] ALSA: core: allow for trigger_tstamp snapshot in .trigger Pierre-Louis Bossart
2015-02-02 10:48   ` Takashi Iwai
2015-01-30 23:55 ` [PATCH v4 03/10] ALSA: hda: read trigger_timestamp immediately after starting DMA Pierre-Louis Bossart
2015-02-02 10:49   ` Takashi Iwai
2015-01-30 23:55 ` Pierre-Louis Bossart [this message]
2015-02-02 10:52   ` [PATCH v4 04/10] ALSA: usb: update trigger timestamp on first non-zero URB submitted Takashi Iwai
2015-01-30 23:55 ` [PATCH v4 05/10] ALSA: core: selection of audio_tstamp type and accuracy reports Pierre-Louis Bossart
2015-01-31  7:37   ` Alexander E. Patrakov
2015-01-31 20:01     ` Pierre-Louis Bossart
2015-01-30 23:55 ` [PATCH v4 06/10] ALSA: core: pass audio tstamp config from userspace Pierre-Louis Bossart
2015-01-30 23:56 ` [PATCH v4 07/10] ALSA: core: pass audio tstamp config from userspace in compat mode Pierre-Louis Bossart
2015-01-30 23:56 ` [PATCH v4 08/10] ALSA: core: replace .wall_clock by .get_time_info Pierre-Louis Bossart
2015-01-30 23:56 ` [PATCH v4 09/10] ALSA: hda: replace .wallclock " Pierre-Louis Bossart
2015-01-30 23:56 ` [PATCH v4 10/10] ALSA: bump PCM protocol to 2.0.13 Pierre-Louis Bossart
2015-02-02 11:03 ` [PATCH v4 00/10] audio timestamping evolutions Takashi Iwai
2015-02-02 15:52   ` Pierre-Louis Bossart
2015-02-02 16:06     ` Takashi Iwai
2015-02-02 16:11       ` Pierre-Louis Bossart
2015-02-02 16:12         ` Takashi Iwai
2015-02-02 16:15       ` Jaroslav Kysela

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=1422662163-7391-5-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 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.