]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: rate - correct the previous fix for snd_pcm_rate_may_wait_for_avail_min()
authorJaroslav Kysela <perex@perex.cz>
Wed, 9 Nov 2022 08:31:34 +0000 (09:31 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 9 Nov 2022 08:35:05 +0000 (09:35 +0100)
The previous fix in aa4f56c3 was not correct. The root of the cause is
implementation in snd_pcm_may_wait_for_avail_min() inline function
where the improper pcm argument is passed to the fast_ops function.

Fixes: aa4f56c3 ("pcm: rate - fix the crash in snd_pcm_rate_may_wait_for_avail_min()")
Fixes: d9dbb57b ("pcm: rate - rewrite the may_wait_for_avail_min callback for the rate plugin")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_local.h
src/pcm/pcm_plugin.c

index 8d25971f6e094e4021aada1fc53e9482cd9097c4..ae0c44bf5497a523ad80029563de642b0817b55e 100644 (file)
@@ -1144,7 +1144,7 @@ static inline int snd_pcm_may_wait_for_avail_min(snd_pcm_t *pcm, snd_pcm_uframes
        if (avail >= pcm->avail_min)
                return 0;
        if (pcm->fast_ops->may_wait_for_avail_min)
-               return pcm->fast_ops->may_wait_for_avail_min(pcm, avail);
+               return pcm->fast_ops->may_wait_for_avail_min(pcm->fast_op_arg, avail);
        return 1;
 }
 
index ec64604cfaa6618679032a156a9e2964de9a2ce2..b3af1fb775035b3e253a16227fd380adc75bc5c7 100644 (file)
@@ -597,8 +597,12 @@ int snd_pcm_plugin_may_wait_for_avail_min_conv(
                 * a) the slave can provide contineous hw_ptr between periods
                 * b) avail_min does not match one slave_period
                 */
-               snd_pcm_plugin_t *plugin = pcm->private_data;
-               snd_pcm_t *slave = plugin->gen.slave;
+               snd_pcm_generic_t *generic = pcm->private_data;
+               /*
+                * do not use snd_pcm_plugin_t pointer here
+                * this code is used from the generic plugins, too
+                */
+               snd_pcm_t *slave = generic->slave;
                snd_pcm_uframes_t needed_slave_avail_min;
                snd_pcm_sframes_t available;
 
@@ -622,7 +626,7 @@ int snd_pcm_plugin_may_wait_for_avail_min_conv(
                 * This code is also used by extplug, but extplug does not allow to alter the sampling rate.
                 */
                if (conv)
-                       needed_slave_avail_min = conv(pcm->fast_op_arg, needed_slave_avail_min);
+                       needed_slave_avail_min = conv(pcm, needed_slave_avail_min);
 
                if (slave->avail_min != needed_slave_avail_min) {
                        snd_pcm_sw_params_t *swparams;