All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH v2 7/7] ALSA: pcm: use exit controlled loop in snd_pcm_playback_silence()
Date: Fri,  5 May 2023 17:52:44 +0200	[thread overview]
Message-ID: <20230505155244.2312199-7-oswald.buddenhagen@gmx.de> (raw)
In-Reply-To: <20230505155244.2312199-1-oswald.buddenhagen@gmx.de>

We already know that `frames` is greater than zero, because we just
checked it. So we don't need to check the loop condition on the first
iteration.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
---
 sound/core/pcm_lib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 17fc80a654be..9c121a921b04 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -123,14 +123,14 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
 	if (frames == 0)
 		return;
 	ofs = (runtime->silence_start + runtime->silence_filled) % runtime->buffer_size;
-	while (frames > 0) {
+	do {
 		transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames;
 		err = fill_silence_frames(substream, ofs, transfer);
 		snd_BUG_ON(err < 0);
 		runtime->silence_filled += transfer;
 		frames -= transfer;
 		ofs = 0;
-	}
+	} while (frames > 0);
 	snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE);
 }
 
-- 
2.40.0.152.g15d061e6df


  parent reply	other threads:[~2023-05-05 15:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 15:52 [PATCH v2 1/7] ALSA: pcm: Revert "ALSA: pcm: rewrite snd_pcm_playback_silence()" Oswald Buddenhagen
2023-05-05 15:52 ` [PATCH v2 2/7] ALSA: pcm: fix playback silence - use the actual new_hw_ptr for the threshold mode Oswald Buddenhagen
2023-05-05 15:52 ` [PATCH v2 3/7] ALSA: pcm: fix playback silence - correct incremental silencing Oswald Buddenhagen
2023-05-05 15:52 ` [PATCH v2 4/7] ALSA: pcm: playback silence - remove extra code Oswald Buddenhagen
2023-05-05 15:52 ` [PATCH v2 5/7] ALSA: pcm: playback silence - move silence variable updates to separate function Oswald Buddenhagen
2023-05-05 15:52 ` [PATCH v2 6/7] ALSA: pcm: simplify top-up mode init in snd_pcm_playback_silence() Oswald Buddenhagen
2023-05-05 15:52 ` Oswald Buddenhagen [this message]
2023-05-05 16:25 ` [PATCH v2 1/7] ALSA: pcm: Revert "ALSA: pcm: rewrite snd_pcm_playback_silence()" Takashi Iwai

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=20230505155244.2312199-7-oswald.buddenhagen@gmx.de \
    --to=oswald.buddenhagen@gmx.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /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.