All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: pcm: Fix source frame count calculation
@ 2026-11-02 14:16 Sreeraj S Kurup
  2026-11-02 14:31 ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Sreeraj S Kurup @ 2026-11-02 14:16 UTC (permalink / raw)
  To: perex, tiwai
  Cc: rosen, cezary.rojewski, tim.bird, linux-sound, linux-kernel,
	Sreeraj S Kurup

Pass the updated frame count to the "src_frames()" callback.

When the next plugin handles fewer frames than requested, use the
actual frame count instead of the original requested count.

This ensures the correct number of source frames is calculated.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 sound/core/oss/pcm_plugin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index acf5ca663ba8..3de713779993 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -604,7 +604,7 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st
 			if (err != frames1) {
 				frames = err;
 				if (plugin->src_frames) {
-					frames = plugin->src_frames(plugin, frames1);
+					frames = plugin->src_frames(plugin, err);
 					if (frames <= 0)
 						return frames;
 				}
-- 
2.55.0


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

* Re: [PATCH] ALSA: pcm: Fix source frame count calculation
  2026-11-02 14:16 [PATCH] ALSA: pcm: Fix source frame count calculation Sreeraj S Kurup
@ 2026-11-02 14:31 ` Takashi Iwai
  2026-11-02 14:47   ` Sreeraj S Kurup
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2026-11-02 14:31 UTC (permalink / raw)
  To: Sreeraj S Kurup
  Cc: perex, tiwai, rosen, cezary.rojewski, tim.bird, linux-sound,
	linux-kernel

On Mon, 02 Nov 2026 15:16:47 +0100,
Sreeraj S Kurup wrote:
> 
> Pass the updated frame count to the "src_frames()" callback.
> 
> When the next plugin handles fewer frames than requested, use the
> actual frame count instead of the original requested count.
> 
> This ensures the correct number of source frames is calculated.
> 
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
> ---
>  sound/core/oss/pcm_plugin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
> index acf5ca663ba8..3de713779993 100644
> --- a/sound/core/oss/pcm_plugin.c
> +++ b/sound/core/oss/pcm_plugin.c
> @@ -604,7 +604,7 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st
>  			if (err != frames1) {
>  				frames = err;
>  				if (plugin->src_frames) {
> -					frames = plugin->src_frames(plugin, frames1);
> +					frames = plugin->src_frames(plugin, err);

Hm, do you really see actually hitting this code path?
As far as I see, the all client_channels() callbacks return the frame
back as given, so the condition (err != frames1) would be always
false.


Takashi

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

* [PATCH] ALSA: pcm: Fix source frame count calculation
@ 2026-11-02 14:34 Sreeraj S Kurup
  0 siblings, 0 replies; 8+ messages in thread
From: Sreeraj S Kurup @ 2026-11-02 14:34 UTC (permalink / raw)
  To: perex, tiwai
  Cc: rosenp, cezary.rojewski, tim.bird, linux-sound, linux-kernel,
	Sreeraj S Kurup

Pass the updated frame count to the "src_frames()" callback.

When the next plugin handles fewer frames than requested, use the
actual frame count instead of the original requested count.

This ensures the correct number of source frames is calculated.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 sound/core/oss/pcm_plugin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index acf5ca663ba8..3de713779993 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -604,7 +604,7 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st
 			if (err != frames1) {
 				frames = err;
 				if (plugin->src_frames) {
-					frames = plugin->src_frames(plugin, frames1);
+					frames = plugin->src_frames(plugin, err);
 					if (frames <= 0)
 						return frames;
 				}
-- 
2.55.0


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

* Re: [PATCH] ALSA: pcm: Fix source frame count calculation
  2026-11-02 14:31 ` Takashi Iwai
@ 2026-11-02 14:47   ` Sreeraj S Kurup
  2026-11-02 15:04     ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Sreeraj S Kurup @ 2026-11-02 14:47 UTC (permalink / raw)
  To: tiwai
  Cc: cezary.rojewski, linux-kernel, linux-sound, perex, rosenp,
	sreekuttan2156239, tim.bird, tiwai

You're right. I checked the callback implementation, and 
"snd_pcm_plugin_client_channels()" always returns the input 
frame count. All plugins created through "snd_pcm_plugin_build()" 
use this callback.

So the condition "err != frames1" is not reached in the normal path. 
My patch is unnecessary. Sorry for the noise.

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

* Re: [PATCH] ALSA: pcm: Fix source frame count calculation
  2026-11-02 14:47   ` Sreeraj S Kurup
@ 2026-11-02 15:04     ` Takashi Iwai
  2026-11-02 15:40       ` Sreeraj S Kurup
  2026-11-03 12:52       ` Sreeraj S Kurup
  0 siblings, 2 replies; 8+ messages in thread
From: Takashi Iwai @ 2026-11-02 15:04 UTC (permalink / raw)
  To: Sreeraj S Kurup
  Cc: tiwai, cezary.rojewski, linux-kernel, linux-sound, perex, rosenp,
	tim.bird, tiwai

On Mon, 02 Nov 2026 15:47:36 +0100,
Sreeraj S Kurup wrote:
> 
> You're right. I checked the callback implementation, and 
> "snd_pcm_plugin_client_channels()" always returns the input 
> frame count. All plugins created through "snd_pcm_plugin_build()" 
> use this callback.
> 
> So the condition "err != frames1" is not reached in the normal path. 
> My patch is unnecessary. Sorry for the noise.

Well, the logic you described looks still correct, so it's better to
correct the code even if it's only hypothetical.

So I applied your patch now with a bit more explanation.


thanks,

Takashi

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

* Re: [PATCH] ALSA: pcm: Fix source frame count calculation
  2026-11-02 15:04     ` Takashi Iwai
@ 2026-11-02 15:40       ` Sreeraj S Kurup
  2026-11-03 12:52       ` Sreeraj S Kurup
  1 sibling, 0 replies; 8+ messages in thread
From: Sreeraj S Kurup @ 2026-11-02 15:40 UTC (permalink / raw)
  To: tiwai
  Cc: cezary.rojewski, linux-kernel, linux-sound, perex, rosenp,
	sreekuttan2156239, tim.bird, tiwai

Hi,

Thanks for reviewing and applying the patch, and for adding the extra explanation.

Best regards,
Sreeraj

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

* Re: [PATCH] ALSA: pcm: Fix source frame count calculation
  2026-11-02 15:04     ` Takashi Iwai
  2026-11-02 15:40       ` Sreeraj S Kurup
@ 2026-11-03 12:52       ` Sreeraj S Kurup
  2026-11-03 14:42         ` Takashi Iwai
  1 sibling, 1 reply; 8+ messages in thread
From: Sreeraj S Kurup @ 2026-11-03 12:52 UTC (permalink / raw)
  To: tiwai
  Cc: cezary.rojewski, linux-kernel, linux-sound, perex, rosenp,
	sreekuttan2156239, tim.bird, tiwai

Hi Takashi,

I would like to kindly follow up on my first patch.

Could you please let me know if you have had a chance to review it?

For reference, here is the patch link:
https://lore.kernel.org/all/20261102135034.2751-1-sreekuttan2156239@gmail.com/

I would appreciate your feedback whenever you have time.

Thank you for your time and consideration.

Best regards,
Sreeraj

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

* Re: [PATCH] ALSA: pcm: Fix source frame count calculation
  2026-11-03 12:52       ` Sreeraj S Kurup
@ 2026-11-03 14:42         ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2026-11-03 14:42 UTC (permalink / raw)
  To: Sreeraj S Kurup
  Cc: tiwai, cezary.rojewski, linux-kernel, linux-sound, perex, rosenp,
	tim.bird, tiwai

On Tue, 03 Nov 2026 13:52:11 +0100,
Sreeraj S Kurup wrote:
> 
> Hi Takashi,
> 
> I would like to kindly follow up on my first patch.
> 
> Could you please let me know if you have had a chance to review it?
> 
> For reference, here is the patch link:
> https://lore.kernel.org/all/20261102135034.2751-1-sreekuttan2156239@gmail.com/
> 
> I would appreciate your feedback whenever you have time.
> 
> Thank you for your time and consideration.

Don't worry, it's still on my TODO to be processed :)


Takashi

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

end of thread, other threads:[~2026-11-03 14:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 14:16 [PATCH] ALSA: pcm: Fix source frame count calculation Sreeraj S Kurup
2026-11-02 14:31 ` Takashi Iwai
2026-11-02 14:47   ` Sreeraj S Kurup
2026-11-02 15:04     ` Takashi Iwai
2026-11-02 15:40       ` Sreeraj S Kurup
2026-11-03 12:52       ` Sreeraj S Kurup
2026-11-03 14:42         ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2026-11-02 14:34 Sreeraj S Kurup

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.