mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
ucm: fix the logic of choosing the default cdev
If the cdev has not been configured explicitly, use the PlaybackCTL or CaptureCTL value if one of them is set. If neither are set, or if both are set to different values, then there's no sensible default, so executing the sequence should fail. The previous code probably tried to implement this logic, but it was buggy. Also use more descriptive variable names than "cdev1" and "cdev2". Signed-off-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
1dd239b781
commit
a102e66440
1 changed files with 23 additions and 11 deletions
|
|
@ -299,8 +299,10 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
case SEQUENCE_ELEMENT_TYPE_CSET:
|
||||
case SEQUENCE_ELEMENT_TYPE_CSET_BIN_FILE:
|
||||
if (cdev == NULL) {
|
||||
const char *cdev1 = NULL, *cdev2 = NULL;
|
||||
err = get_value3(&cdev1, "PlaybackCTL",
|
||||
const char *playback_ctl = NULL;
|
||||
const char *capture_ctl = NULL;
|
||||
|
||||
err = get_value3(&playback_ctl, "PlaybackCTL",
|
||||
value_list1,
|
||||
value_list2,
|
||||
value_list3);
|
||||
|
|
@ -308,23 +310,33 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
uc_error("cdev is not defined!");
|
||||
return err;
|
||||
}
|
||||
err = get_value3(&cdev2, "CaptureCTL",
|
||||
err = get_value3(&capture_ctl, "CaptureCTL",
|
||||
value_list1,
|
||||
value_list2,
|
||||
value_list3);
|
||||
if (err < 0 && err != -ENOENT) {
|
||||
free((char *)cdev1);
|
||||
free((char *)playback_ctl);
|
||||
uc_error("cdev is not defined!");
|
||||
return err;
|
||||
}
|
||||
if (cdev1 == NULL || cdev2 == NULL ||
|
||||
strcmp(cdev1, cdev2) == 0) {
|
||||
cdev = (char *)cdev1;
|
||||
free((char *)cdev2);
|
||||
} else {
|
||||
free((char *)cdev1);
|
||||
free((char *)cdev2);
|
||||
if (playback_ctl == NULL &&
|
||||
capture_ctl == NULL) {
|
||||
uc_error("cdev is not defined!");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (playback_ctl != NULL &&
|
||||
capture_ctl != NULL &&
|
||||
strcmp(playback_ctl, capture_ctl) != 0) {
|
||||
free((char *)playback_ctl);
|
||||
free((char *)capture_ctl);
|
||||
uc_error("cdev is not defined!");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (playback_ctl != NULL) {
|
||||
cdev = (char *)playback_ctl;
|
||||
free((char *)capture_ctl);
|
||||
} else
|
||||
cdev = (char *)capture_ctl;
|
||||
}
|
||||
if (ctl == NULL) {
|
||||
err = open_ctl(uc_mgr, &ctl, cdev);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue