Commit ee2dd703 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen Committed by Takashi Iwai

ALSA: pcm: use exit controlled loop in snd_pcm_playback_silence()

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: default avatarOswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230505155244.2312199-7-oswald.buddenhagen@gmx.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6ffa6f39
...@@ -123,14 +123,14 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram ...@@ -123,14 +123,14 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
if (frames == 0) if (frames == 0)
return; return;
ofs = (runtime->silence_start + runtime->silence_filled) % runtime->buffer_size; 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; transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames;
err = fill_silence_frames(substream, ofs, transfer); err = fill_silence_frames(substream, ofs, transfer);
snd_BUG_ON(err < 0); snd_BUG_ON(err < 0);
runtime->silence_filled += transfer; runtime->silence_filled += transfer;
frames -= transfer; frames -= transfer;
ofs = 0; ofs = 0;
} } while (frames > 0);
snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment