From fa797c860d474d0efd5dfb4e491917ea2bb9bfe5 Mon Sep 17 00:00:00 2001 From: jpka Date: Sun, 31 May 2026 10:34:27 +0300 Subject: [PATCH 1/8] Update pcm.h --- include/pcm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/pcm.h b/include/pcm.h index f8c84875c..e3f103ad8 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -732,6 +732,10 @@ void snd_pcm_info_set_stream(snd_pcm_info_t *obj, snd_pcm_stream_t val); * \{ */ +#define SND_PCM_LIMIT_HW_RATE_MIN 4000 /**< minimal allowed rate for hardware */ +#define SND_PCM_LIMIT_HW_RATE_MAX 768000 /**< maximal allowed rate for hardware */ +#define SND_PCM_LIMIT_HW_CHANNELS_MAX 512 /**< maximal number of channels for hardware */ + int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); int snd_pcm_hw_params_can_mmap_sample_resolution(const snd_pcm_hw_params_t *params); @@ -925,6 +929,10 @@ int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_u * \{ */ +#define SND_PCM_LIMIT_SW_RATE_MIN SND_PCM_LIMIT_HW_RATE_MIN /**< minimal allowed rate for software, should be not greater than minimal rate allowed by supported hardware */ +#define SND_PCM_LIMIT_SW_RATE_MAX SND_PCM_LIMIT_HW_RATE_MAX /**< maximal allowed rate for software, should be not less than maximal rate allowed by supported hardware */ +#define SND_PCM_LIMIT_SW_CHANNELS_MAX 10000 /**< maximal number of channels for software, should be not less than maximal number of channels supported by hardware */ + size_t snd_pcm_sw_params_sizeof(void); /** \hideinitializer * \brief allocate an invalid #snd_pcm_sw_params_t using standard alloca From cd7c5e3578dbaf9737652a16e703fb4da7f413b4 Mon Sep 17 00:00:00 2001 From: jpka Date: Sun, 31 May 2026 10:36:22 +0300 Subject: [PATCH 2/8] Update pcm_plugin.h --- include/pcm_plugin.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/pcm_plugin.h b/include/pcm_plugin.h index 35be5e597..7c8d2892b 100644 --- a/include/pcm_plugin.h +++ b/include/pcm_plugin.h @@ -39,9 +39,6 @@ * \{ */ -#define SND_PCM_PLUGIN_RATE_MIN 4000 /**< minimal rate for the rate plugin */ -#define SND_PCM_PLUGIN_RATE_MAX 768000 /**< maximal rate for the rate plugin */ - /* ROUTE_FLOAT should be set to 0 for machines without FP unit - like iPAQ */ #ifdef HAVE_SOFT_FLOAT #define SND_PCM_PLUGIN_ROUTE_FLOAT 0 /**< use integers for route plugin */ From 583de52a505b88630bc646f8b6bc5c88fd08bf2c Mon Sep 17 00:00:00 2001 From: jpka Date: Sun, 31 May 2026 10:38:13 +0300 Subject: [PATCH 3/8] Update pcm_plug.c --- src/pcm/pcm_plug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index ddda92cad..34f8caf34 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -726,8 +726,8 @@ static int snd_pcm_plug_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ err = snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_RATE, &rate_min, NULL); if (err < 0) return err; - if (rate_min < 4000) { - _snd_pcm_hw_param_set_min(params, SND_PCM_HW_PARAM_RATE, 4000, 0); + if (rate_min < SND_PCM_LIMIT_HW_RATE_MIN) { + _snd_pcm_hw_param_set_min(params, SND_PCM_HW_PARAM_RATE, SND_PCM_LIMIT_HW_RATE_MIN, 0); if (snd_pcm_hw_param_empty(params, SND_PCM_HW_PARAM_RATE)) return -EINVAL; } @@ -735,8 +735,8 @@ static int snd_pcm_plug_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ err = snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_CHANNELS, &channels_max, NULL); if (err < 0) return err; - if (channels_max > 10000) { - _snd_pcm_hw_param_set_max(params, SND_PCM_HW_PARAM_CHANNELS, 10000, 0); + if (channels_max > SND_PCM_LIMIT_HW_CHANNELS_MAX) { + _snd_pcm_hw_param_set_max(params, SND_PCM_HW_PARAM_CHANNELS, SND_PCM_LIMIT_HW_CHANNELS_MAX, 0); if (snd_pcm_hw_param_empty(params, SND_PCM_HW_PARAM_CHANNELS)) return -EINVAL; } From 2b58530977558ce2efd9a9258ae845451ed06560 Mon Sep 17 00:00:00 2001 From: jpka Date: Sun, 31 May 2026 10:39:08 +0300 Subject: [PATCH 4/8] Update pcm_rate.c --- src/pcm/pcm_rate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index d54be3c22..f3a3a986e 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -1528,8 +1528,8 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, rate->srate = srate; rate->sformat = sformat; - rate->rate_min = SND_PCM_PLUGIN_RATE_MIN; - rate->rate_max = SND_PCM_PLUGIN_RATE_MAX; + rate->rate_min = SND_PCM_LIMIT_SW_RATE_MIN; + rate->rate_max = SND_PCM_LIMIT_SW_RATE_MAX; rate->plugin_version = SND_PCM_RATE_PLUGIN_VERSION; err = snd_pcm_new(&pcm, SND_PCM_TYPE_RATE, name, slave->stream, slave->mode); From d99f2d7d341ed4e00e7cdc18d4abd7a34596d588 Mon Sep 17 00:00:00 2001 From: jpka Date: Sun, 31 May 2026 10:40:07 +0300 Subject: [PATCH 5/8] Update pcm_rate_linear.c --- src/pcm/pcm_rate_linear.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pcm/pcm_rate_linear.c b/src/pcm/pcm_rate_linear.c index 913a192a7..9ef030030 100644 --- a/src/pcm/pcm_rate_linear.c +++ b/src/pcm/pcm_rate_linear.c @@ -28,7 +28,7 @@ #include -/* LINEAR_DIV needs to be large enough to handle resampling from 768000 -> 8000 */ +/* LINEAR_DIV needs to be large enough to handle resampling from SND_PCM_LIMIT_SW_RATE_MAX to SND_PCM_LIMIT_SW_RATE_MIN, like 768000 -> 8000 */ #define LINEAR_DIV_SHIFT 19 #define LINEAR_DIV (1< Date: Sun, 31 May 2026 10:41:25 +0300 Subject: [PATCH 6/8] Update pcm_simple.c --- src/pcm/pcm_simple.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pcm/pcm_simple.c b/src/pcm/pcm_simple.c index c0bc1a2a8..36f846c5d 100644 --- a/src/pcm/pcm_simple.c +++ b/src/pcm/pcm_simple.c @@ -170,8 +170,8 @@ int snd_spcm_init(snd_pcm_t *pcm, unsigned int buffer_time; assert(pcm); - assert(rate >= 5000 && rate <= 786000); - assert(channels >= 1 && channels <= 512); + assert(rate >= SND_PCM_LIMIT_HW_RATE_MIN && rate <= SND_PCM_LIMIT_HW_RATE_MAX); + assert(channels >= 1 && channels <= SND_PCM_LIMIT_HW_CHANNELS_MAX); rrate = rate; err = set_buffer_time(latency, &buffer_time); @@ -227,8 +227,8 @@ int snd_spcm_init_duplex(snd_pcm_t *playback_pcm, assert(playback_pcm); assert(capture_pcm); - assert(rate >= 5000 && rate <= 768000); - assert(channels >= 1 && channels <= 512); + assert(rate >= SND_PCM_LIMIT_HW_RATE_MIN && rate <= SND_PCM_LIMIT_HW_RATE_MAX); + assert(channels >= 1 && channels <= SND_PCM_LIMIT_HW_CHANNELS_MAX); pcms[0] = playback_pcm; pcms[1] = capture_pcm; From e70039ad26781e92522e48b6f7d8cbc7c1f758ab Mon Sep 17 00:00:00 2001 From: jpka Date: Sun, 31 May 2026 10:42:22 +0300 Subject: [PATCH 7/8] Update latency.c --- test/latency.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/latency.c b/test/latency.c index 38633253a..736301b33 100644 --- a/test/latency.c +++ b/test/latency.c @@ -630,7 +630,7 @@ int main(int argc, char *argv[]) break; case 'r': err = atoi(optarg); - rate = err >= 4000 && err < 200000 ? err : 44100; + rate = err >= SND_PCM_LIMIT_SW_RATE_MIN && err < SND_PCM_LIMIT_SW_RATE_MAX ? err : 44100; break; case 'B': err = atoi(optarg); From 63ec4d294472acadeb4ee3a31a819bfb432e72aa Mon Sep 17 00:00:00 2001 From: jpka Date: Sun, 31 May 2026 10:43:26 +0300 Subject: [PATCH 8/8] Update pcm.c --- test/pcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/pcm.c b/test/pcm.c index 6e8ae9e4b..247a7bdac 100644 --- a/test/pcm.c +++ b/test/pcm.c @@ -810,13 +810,13 @@ int main(int argc, char *argv[]) break; case 'r': rate = atoi(optarg); - rate = rate < 4000 ? 4000 : rate; - rate = rate > 196000 ? 196000 : rate; + rate = rate < SND_PCM_LIMIT_HW_RATE_MIN ? SND_PCM_LIMIT_HW_RATE_MIN : rate; + rate = rate > SND_PCM_LIMIT_HW_RATE_MAX ? SND_PCM_LIMIT_HW_RATE_MAX : rate; break; case 'c': channels = atoi(optarg); channels = channels < 1 ? 1 : channels; - channels = channels > 1024 ? 1024 : channels; + channels = channels > SND_PCM_LIMIT_HW_CHANNELS_MAX ? SND_PCM_LIMIT_HW_CHANNELS_MAX : channels; break; case 'f': freq = atoi(optarg);