Closed Saur2000 closed 2 years ago
The function is not very universal. Could you link to your source to reconsider the removal?
This is in proprietary code, so I cannot link to it. However, I have extracted the relevant function. I have removed most error handling to keep it shorter, and also removed or obfuscated code that should not be relevant for the issue:
static int plugin_control_load_user_control(snd_config_t *control_config, snd_pcm_t *pcm, UserControl *user_control)
{
int err, card = -1, cchannels = 2;
char tmp_name[32];
snd_pcm_info_t *pcm_info = NULL;
err = snd_ctl_elem_id_malloc(&user_control->id);
err = snd_ctl_elem_info_malloc(&user_control->info);
err = snd_ctl_elem_value_malloc(&user_control->value);
err = snd_pcm_parse_control_id(control_config, user_control->id, &card, &cchannels, NULL);
if (card < 0) {
err = snd_pcm_info_malloc(&pcm_info);
err = snd_pcm_info(pcm, pcm_info);
card = snd_pcm_info_get_card(pcm_info);
snd_pcm_info_free(pcm_info);
if (card < 0) {
return -EINVAL;
}
}
sprintf(tmp_name, "hw:%d", card);
err = snd_ctl_open(&user_control->control_handle, tmp_name, SND_CTL_NONBLOCK);
snd_ctl_elem_value_set_id(user_control->value, user_control->id);
snd_ctl_elem_info_set_id(user_control->info, user_control->id);
err = snd_ctl_elem_info(user_control->control_handle, user_control->info);
if (err < 0) {
const char *name;
if (err != -ENOENT) {
return err;
}
name = snd_ctl_elem_info_get_name(user_control->info);
if (strcmp(name, USER_CONTROL_NAME_ENABLED) == 0) {
err = some_function(user_control, cchannels, false);
} else {
return -EINVAL;
}
err = snd_ctl_elem_unlock(user_control->control_handle, user_control->id);
}
return 0;
}
Also note that I am not responsible for this code. I am just trying to make it build with a newer version of alsa-lib as part of updating our platform to Poky Honister from the Yocto Project.
I added the code back (will be in 1.2.6) with the deprecated attribute in f0d540f851de3992a5e285dcea0be7cab293527e . Anyway, I suggest to copy the code to the caller. Called functions (from snd_pcm_parse_control_id()
are available).
It seems
snd_pcm_parse_control_id()
was made private in 1.2.5 without any prior deprecation. It is still present inpcm_external.h
, and our code now fails to link with:What are we supposed to use instead? And why is the function still in the header file if it is not in the library?