[alsa-devel] alsalib and snd_pcm_hw_params_set_rate_minmax
Oleksandr Andrushchenko
andr2000 at gmail.com
Thu Mar 15 13:20:14 CET 2018
On 03/15/2018 01:59 PM, Takashi Sakamoto wrote:
> Hi,
>
> On Mar 15 2018 19:45, Oleksandr Andrushchenko wrote:
>> Is it possible for user-space to reduce configuration space
>> with snd_pcm_hw_params_set_rate_minmax and then change it
>> with another snd_pcm_hw_params_set_rate_minmax with values
>> out of the reduced config?
>>
>> For example, the initial min/max is 44100/48000 and I set 44100
>> first, e.g.
>>
>> snd_pcm_hw_params_set_rate_minmax(handle, hw_params, 44100, 0, 44100, 0)
>>
>> and then want
>>
>> snd_pcm_hw_params_set_rate_minmax(handle, hw_params, 48000, 0, 48000, 0)
>>
>> Obviously, the last call fails as we have already a reduced
>> space of [44100; 44100].
>>
>> Is there a way I can still set the range to [48000; 48000]?
>>
>> Thank you,
>> Oleksandr
>>
>> P.S. This is in context of work done for [1]
>>
>> [1] https://www.spinics.net/lists/alsa-devel/msg75382.html
>
> We can't. Once shrinking available interval of a parameter, we cannot
> expand it again without initializing the parameter on memory object for
> 'struct snd_pcm_hw_params_t', in which actual layout is never disclosed
> to user applications.
So, this effectively means that this is a one way road, if you need to
change
some parameter you'll need to start all over, so the whole configuration
space remains consistent :(
>
> If you can initialize whole the parameters, snd_pcm_hw_params_any() is
> available for your purpose, then set min/max rate again.
This is what I do now but...
> But just for
> one of the parameters, in my opinion, we need to open an internal API;
> snd_pcm_hw_param_any()[1].
IMO, this will lead to the false assumption that configuration is possible.
For example, I set 4 channels and 44100, but then, after
snd_pcm_hw_params_any,
set 48000 and might assume that the configuration is still possible. But
this may not
be true: it is true for the configuration returned by snd_pcm_hw_param_any
as we don't know about 4 channels yet. But might not be allowed if we
want 4 channels
and 48000 at the same time.
>
> [1]
> http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm_params.c;h=608a2324cb268f84d91f67c53d979521678f4edb;hb=HEAD#l107
>
>
> Regards
>
> Takashi Sakamoto
Thank you very much for explanation,
Oleksandr
More information about the Alsa-devel
mailing list