From: Takashi Iwai Subject: Re: [PATCH v4 04/10] ALSA: usb: update trigger timestamp on first non-zero URB submitted Date: Mon, 02 Feb 2015 11:52:47 +0100 Message-ID: References: <1422662163-7391-1-git-send-email-pierre-louis.bossart@linux.intel.com> <1422662163-7391-5-git-send-email-pierre-louis.bossart@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 7FCD42604DB for ; Mon, 2 Feb 2015 11:52:47 +0100 (CET) In-Reply-To: <1422662163-7391-5-git-send-email-pierre-louis.bossart@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Fri, 30 Jan 2015 17:55:57 -0600, Pierre-Louis Bossart wrote: > > 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 > --- > 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) { Ah I see that trigger_tstamp_pending_update is used here at first. But then I wonder whether this is specific to USB-audio, if there is no relevant code in PCM core side? If so, we don't need to add the field to snd_pcm_runtime but to snb_usb_usbstream instead. (BTW, for boolean, avoid use of 0 and 1.) thanks, Takashi > + /* 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 > > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel >