mirror of https://lore.kernel.org/lkml/
 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; 6+ 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	[flat|nested] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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
  0 siblings, 1 reply; 6+ 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] 6+ 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
  0 siblings, 0 replies; 6+ 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] 6+ messages in thread

* [PATCH] ALSA: pcm: Fix source frame count calculation
@ 2026-11-02 14:34 Sreeraj S Kurup
  0 siblings, 0 replies; 6+ 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	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-02 15:41 UTC | newest]

Thread overview: 6+ 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-02 14:34 Sreeraj S Kurup

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

all inboxes | Powered by JetHome®