From: Takashi Iwai <tiwai@suse.de>
To: Mike Brady <mikebrady@eircom.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>,
devel@driverdev.osuosl.org, alsa-devel@alsa-project.org,
f.fainelli@gmail.com, Eric Anholt <eric@anholt.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, julia.lawall@lip6.fr,
linux-rpi-kernel@lists.infradead.org,
nishka.dasgupta_ug18@ashoka.edu.in,
Kirill Marinushkin <k.marinushkin@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] ARM: staging: bcm2835-audio: interpolate audio delay
Date: Tue, 13 Nov 2018 17:50:37 +0100 [thread overview]
Message-ID: <s5h7ehgdiqq.wl-tiwai@suse.de> (raw)
In-Reply-To: <B1CDD261-AB22-43CE-AF46-DFB5460B5D50@eircom.net>
On Sun, 11 Nov 2018 19:21:29 +0100,
Mike Brady wrote:
>
> /* hardware definition */
> static const struct snd_pcm_hardware snd_bcm2835_playback_hw = {
> .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
> SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
> - SNDRV_PCM_INFO_DRAIN_TRIGGER | SNDRV_PCM_INFO_SYNC_APPLPTR),
> + SNDRV_PCM_INFO_BATCH | SNDRV_PCM_INFO_DRAIN_TRIGGER |
> + SNDRV_PCM_INFO_SYNC_APPLPTR),
As already mentioned, the addition of SNDRV_PCM_INFO_BATCH should be
irrelevant with this change. Please create another patch to add this
and clarify it in the changelog.
> diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
> index 4e6110d778bd..574df7d7a1fa 100644
> --- a/sound/core/pcm_lib.c
> +++ b/sound/core/pcm_lib.c
> @@ -229,19 +229,38 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream,
> (runtime->audio_tstamp_report.actual_type ==
> SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) {
>
> - /*
> - * provide audio timestamp derived from pointer position
> - * add delay only if requested
> - */
> + // provide audio timestamp derived from pointer position
>
> audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr;
>
> - if (runtime->audio_tstamp_config.report_delay) {
> + /*
> + * If the runtime->delay is greater than zero, it's a
> + * genuine delay, e.g. a delay due to a hardware fifo.
> + *
> + * But if the runtime->delay is less than zero, it's an
> + * interpolated estimate of the number of frames output
> + * since the hardware pointer was last updated.
> + *
> + * It would be calculated in the pointer callback.
> + * For example, for the bcm_2835 driver, it is calculated in
> + * snd_bcm2835_pcm_pointer().
> + */
> +
> + if (runtime->delay < 0) {
> + // The delay is an interpolated estimate...
> if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> - audio_frames -= runtime->delay;
> - else
> - audio_frames += runtime->delay;
> + audio_frames += runtime->delay;
> + } else {
> + // The delay is a real delay. Add it if requested.
> + if (runtime->audio_tstamp_config.report_delay) {
> + if (substream->stream ==
> + SNDRV_PCM_STREAM_PLAYBACK)
> + audio_frames -= runtime->delay;
> + else
> + audio_frames += runtime->delay;
> + }
> }
Well, honestly speaking, I'm really not fond of changing the PCM core
just for this.
Can we make bcm audio driver providing the finer pointer update
instead? If we have a module option to disable that behavior, it's an
enough excuse in case anyone really cares about the accuracy.
thanks,
Takashi
next prev parent reply other threads:[~2018-11-13 16:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-18 10:57 [PATCH] staging: bcm2835-audio: interpolate audio delay Mike Brady
2018-10-18 11:02 ` Takashi Iwai
2018-10-18 19:48 ` Kirill Marinushkin
2018-10-22 19:08 ` Mike Brady
2018-10-22 19:17 ` [PATCH v2] " Mike Brady
2018-10-22 22:25 ` Kirill Marinushkin
2018-10-24 8:20 ` [alsa-devel] " Mike Brady
2018-10-24 18:06 ` Kirill Marinushkin
2018-10-24 19:54 ` Mike Brady
2018-10-24 22:02 ` Kirill Marinushkin
2018-10-25 7:37 ` Takashi Iwai
2018-10-25 17:20 ` Kirill Marinushkin
2018-10-28 14:24 ` Mike Brady
2018-10-28 14:26 ` Mike Brady
2018-11-05 15:57 ` Mike Brady
2018-11-05 16:11 ` Takashi Iwai
2018-11-06 21:05 ` Mike Brady
2018-11-06 21:31 ` Takashi Iwai
2018-11-11 18:08 ` Mike Brady
2018-11-11 18:21 ` [PATCH v2] ARM: " Mike Brady
2018-11-11 20:18 ` Stefan Wahren
2018-11-13 16:50 ` Takashi Iwai [this message]
2019-01-01 10:02 ` Mike Brady
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=s5h7ehgdiqq.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=devel@driverdev.osuosl.org \
--cc=eric@anholt.net \
--cc=f.fainelli@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=julia.lawall@lip6.fr \
--cc=k.marinushkin@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=mikebrady@eircom.net \
--cc=nishka.dasgupta_ug18@ashoka.edu.in \
--cc=stefan.wahren@i2se.com \
/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).