diff options
author | Tanu Kaskinen <tanuk@iki.fi> | 2015-10-23 12:36:34 +0300 |
---|---|---|
committer | Tanu Kaskinen <tanuk@iki.fi> | 2016-06-28 16:55:42 +0300 |
commit | 59e76ca9499fb3b1a6dcfb0525b93b61eb6c1de2 (patch) | |
tree | f241d1ffbe427db9287c9e998845ef996b242ab4 /src | |
parent | 87f437d0ddbf16312130f72385c901b28ba980b6 (diff) |
alsa, bluetooth: fail if user-requested profile doesn't exist
If we can't fulfill the user request fully, I think we shouldn't
fulfill it at all, to make it clear that the requested operation
didn't succeed.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/alsa/module-alsa-card.c | 11 | ||||
-rw-r--r-- | src/modules/bluetooth/module-bluez4-device.c | 7 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c index adb942b4a..ae3a03505 100644 --- a/src/modules/alsa/module-alsa-card.c +++ b/src/modules/alsa/module-alsa-card.c @@ -807,8 +807,15 @@ int pa__init(pa_module *m) { goto fail; } - if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL))) - pa_card_new_data_set_profile(&data, profile); + if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL))) { + if (pa_hashmap_get(data.profiles, profile)) + pa_card_new_data_set_profile(&data, profile); + else { + pa_log("No such profile: %s", profile); + pa_card_new_data_done(&data); + goto fail; + } + } u->card = pa_card_new(m->core, &data); pa_card_new_data_done(&data); diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c index 9a921a528..a2de5256e 100644 --- a/src/modules/bluetooth/module-bluez4-device.c +++ b/src/modules/bluetooth/module-bluez4-device.c @@ -2301,8 +2301,11 @@ static int add_card(struct userdata *u) { if ((default_profile = pa_modargs_get_value(u->modargs, "profile", NULL))) { if (pa_hashmap_get(data.profiles, default_profile)) pa_card_new_data_set_profile(&data, default_profile); - else - pa_log_warn("Profile '%s' not valid or not supported by device.", default_profile); + else { + pa_log("Profile '%s' not valid or not supported by device.", default_profile); + pa_card_new_data_done(&data); + return -1; + } } u->card = pa_card_new(u->core, &data); |