diff mbox series

[2/7] ALSA: pcm: fix playback silence - use the actual new_hw_ptr for the threshold mode

Message ID 20230505103140.2285622-2-oswald.buddenhagen@gmx.de
State Superseded
Headers show
Series [1/7] ALSA: pcm: Revert "ALSA: pcm: rewrite snd_pcm_playback_silence()" | expand

Commit Message

Oswald Buddenhagen May 5, 2023, 10:31 a.m. UTC
From: Jaroslav Kysela <perex@perex.cz>

The snd_pcm_playback_hw_avail() function uses runtime->status->hw_ptr.
Unfortunately, in case when we call this function from snd_pcm_update_hw_ptr0(),
this variable contains the previous hardware pointer. Use the new_hw_ptr
argument to calculate hw_avail (filled samples by the user space) to
correct the threshold comparison.

The new_hw_ptr argument may also be set to ULONG_MAX which means the
initialization phase. In this case, use runtime->status->hw_ptr.

Suggested-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
---
 sound/core/pcm_lib.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Takashi Iwai May 5, 2023, 3:22 p.m. UTC | #1
On Fri, 05 May 2023 12:31:35 +0200,
Oswald Buddenhagen wrote:
> 
> From: Jaroslav Kysela <perex@perex.cz>
> 
> The snd_pcm_playback_hw_avail() function uses runtime->status->hw_ptr.
> Unfortunately, in case when we call this function from snd_pcm_update_hw_ptr0(),
> this variable contains the previous hardware pointer. Use the new_hw_ptr
> argument to calculate hw_avail (filled samples by the user space) to
> correct the threshold comparison.
> 
> The new_hw_ptr argument may also be set to ULONG_MAX which means the
> initialization phase. In this case, use runtime->status->hw_ptr.
> 
> Suggested-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>

Here misses your Signed-off-by tag.  Ditto for the patch 3.
It's a legal requirement, and I can't apply patches without it.

Could you resubmit the series quickly with your SOB?


thanks,

Takashi
Takashi Iwai May 5, 2023, 4:22 p.m. UTC | #2
On Fri, 05 May 2023 17:52:11 +0200,
Oswald Buddenhagen wrote:
> 
> On Fri, May 05, 2023 at 05:22:57PM +0200, Takashi Iwai wrote:
> > On Fri, 05 May 2023 12:31:35 +0200,
> > Oswald Buddenhagen wrote:
> >> Suggested-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
> >> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
> >> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
> > 
> > Here misses your Signed-off-by tag.  Ditto for the patch 3.
> > It's a legal requirement, and I can't apply patches without it.
> > 
> i assumed reviewed-by would be a superset, but apparently it's not.
> however, there is no need to add SOB to patches which i only reviewed
> or suggested.

SOB is needed by a person who submitted, no matter whether any other
tags are present.  So, it's still mandatory in this case.

> i'll adjust the patches to which i made substantial
> modifications, though.

Great, thanks!


Takashi
Oswald Buddenhagen May 5, 2023, 4:32 p.m. UTC | #3
On Fri, May 05, 2023 at 06:22:15PM +0200, Takashi Iwai wrote:
>On Fri, 05 May 2023 17:52:11 +0200, Oswald Buddenhagen wrote:
>> however, there is no need to add SOB to patches which i only reviewed
>> or suggested.
>
>SOB is needed by a person who submitted, no matter whether any other
>tags are present.  So, it's still mandatory in this case.
>
pedantically, yes. you can link to perex' patch instead, as it's 
literally the same one, sans the reviewed-by.

(i don't think any of this really matters for re-posts of patches that 
have been publicly posted to the same list a few hours prior, as any 
legal challenge could be resolved within minutes anyway.)

regards
diff mbox series

Patch

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 3357ffae635f..6ad67e7e740c 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -63,7 +63,15 @@  void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
 		}
 		if (runtime->silence_filled >= runtime->buffer_size)
 			return;
-		noise_dist = snd_pcm_playback_hw_avail(runtime) + runtime->silence_filled;
+		/* initialization outside pointer updates */
+		if (new_hw_ptr == ULONG_MAX)
+			new_hw_ptr = runtime->status->hw_ptr;
+		/* get hw_avail with the boundary crossing */
+		noise_dist = appl_ptr - new_hw_ptr;
+		if (noise_dist < 0)
+			noise_dist += runtime->boundary;
+		/* total noise distance */
+		noise_dist += runtime->silence_filled;
 		if (noise_dist >= (snd_pcm_sframes_t) runtime->silence_threshold)
 			return;
 		frames = runtime->silence_threshold - noise_dist;