diff options
author | Tanu Kaskinen <tanu.kaskinen@linux.intel.com> | 2015-02-17 21:15:22 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-02-17 22:15:53 +0100 |
commit | a102e66440c7579e9a82ee869b7dc7a53393e3df (patch) | |
tree | 34ffd5bdc05f4c173212d263dc59d9dfda9f8020 | |
parent | 1dd239b781402d21aa84ff9783926bb972547595 (diff) | |
download | alsa-lib-a102e66440c7579e9a82ee869b7dc7a53393e3df.tar.gz |
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>
-rw-r--r-- | src/ucm/main.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/ucm/main.c b/src/ucm/main.c index efb5be5d..81a0950e 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -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); |