Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: pcm: Update hardware pointer before start capture
@ 2018-09-07 19:58 Ricardo Biehl Pasquali
  2018-09-10  7:07 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo Biehl Pasquali @ 2018-09-07 19:58 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai

This ensures the transfer loop won't waste a run to read
the few frames (if any) between start and hw_ptr update.
It will wait for the next interrupt with wait_for_avail().

Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
---
 sound/core/pcm_lib.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 7f71c2449..40013b26f 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -2172,6 +2172,10 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
 	if (err < 0)
 		goto _end_unlock;
 
+	runtime->twake = runtime->control->avail_min ? : 1;
+	if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
+		snd_pcm_update_hw_ptr(substream);
+
 	if (!is_playback &&
 	    runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
 		if (size >= runtime->start_threshold) {
@@ -2185,10 +2189,8 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
 		}
 	}
 
-	runtime->twake = runtime->control->avail_min ? : 1;
-	if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
-		snd_pcm_update_hw_ptr(substream);
 	avail = snd_pcm_avail(substream);
+
 	while (size > 0) {
 		snd_pcm_uframes_t frames, appl_ptr, appl_ofs;
 		snd_pcm_uframes_t cont;
-- 
2.17.1

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

* Re: [PATCH] ALSA: pcm: Update hardware pointer before start capture
  2018-09-07 19:58 [PATCH] ALSA: pcm: Update hardware pointer before start capture Ricardo Biehl Pasquali
@ 2018-09-10  7:07 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2018-09-10  7:07 UTC (permalink / raw)
  To: Ricardo Biehl Pasquali; +Cc: alsa-devel

On Fri, 07 Sep 2018 21:58:54 +0200,
Ricardo Biehl Pasquali wrote:
> 
> This ensures the transfer loop won't waste a run to read
> the few frames (if any) between start and hw_ptr update.
> It will wait for the next interrupt with wait_for_avail().
> 
> Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>

Applied, thanks.


Takashi

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

end of thread, other threads:[~2018-09-10  7:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-07 19:58 [PATCH] ALSA: pcm: Update hardware pointer before start capture Ricardo Biehl Pasquali
2018-09-10  7:07 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox