Skip to contentSkip to conversation

ALSA: pcm: Fix source frame count calculation

PATCH In review Sreeraj S Kurup 2 participants 7 messages Nov 2 – Nov 3 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pcm: Fix source frame count calculation

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.

---
 sound/core/oss/pcm_plugin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/oss/pcm_plugin.c +1 -1
index acf5ca663ba8..3de713779993 100644
@@ -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;
 				}
Signature · 1 line
2.55.0
#1 lore raw
Quoted 18 lines · 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.

---
 sound/core/oss/pcm_plugin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/oss/pcm_plugin.c +0 -0
index acf5ca663ba8..3de713779993 100644

sound/core/oss/pcm_plugin.c snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st · line 607

Quoted 5 lines
sound/core/oss/pcm_plugin.c +1 -1
@@ -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

#2 lore raw

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.

#3 lore raw
Quoted 8 lines · Sreeraj S Kurup

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

#4 lore raw

Hi,

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

Best regards,
Sreeraj

#6 lore raw
Quoted 5 lines · Sreeraj S Kurup

Hi Takashi,

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

Quoted 8 lines

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/[email protected]/

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