blob: be3655b23cfcb6df6e8993da300ca9b4a88f9ba9 [file] [log] [blame]
Patrick Williamsf1e5d692016-03-30 15:21:19 -05001From 339eb179baa7810113f6456accc05b3a32c1cdba Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Fri, 23 Oct 2015 12:36:34 +0300
4Subject: [PATCH 2/4] alsa, bluetooth: fail if user-requested profile doesn't
5 exist
6
7If we can't fulfill the user request fully, I think we shouldn't
8fulfill it at all, to make it clear that the requested operation
9didn't succeed.
10
11http://bugzilla.yoctoproject.org/show_bug.cgi?id=8448
12
Patrick Williamsf1e5d692016-03-30 15:21:19 -050013Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050014
15Upstream-Status: Denied [The patch set needs some work to be accepted.
16The review thread:
17http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/24301]
18
19Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
Patrick Williamsf1e5d692016-03-30 15:21:19 -050020---
21 src/modules/alsa/module-alsa-card.c | 10 ++++++++--
22 src/modules/bluetooth/module-bluez4-device.c | 6 ++++--
23 2 files changed, 12 insertions(+), 4 deletions(-)
24
25diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
26index a7fec04..32f517e 100644
27--- a/src/modules/alsa/module-alsa-card.c
28+++ b/src/modules/alsa/module-alsa-card.c
29@@ -754,8 +754,14 @@ int pa__init(pa_module *m) {
30 goto fail;
31 }
32
33- if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL)))
34- pa_card_new_data_set_profile(&data, profile);
35+ if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
36+ if (pa_hashmap_get(data.profiles, profile))
37+ pa_card_new_data_set_profile(&data, profile);
38+ else {
39+ pa_log("No such profile: %s", profile);
40+ goto fail;
41+ }
42+ }
43
44 u->card = pa_card_new(m->core, &data);
45 pa_card_new_data_done(&data);
46diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c
47index b40c6a0..94e6988 100644
48--- a/src/modules/bluetooth/module-bluez4-device.c
49+++ b/src/modules/bluetooth/module-bluez4-device.c
50@@ -2310,8 +2310,10 @@ static int add_card(struct userdata *u) {
51 if ((default_profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
52 if (pa_hashmap_get(data.profiles, default_profile))
53 pa_card_new_data_set_profile(&data, default_profile);
54- else
55- pa_log_warn("Profile '%s' not valid or not supported by device.", default_profile);
56+ else {
57+ pa_log("Profile '%s' not valid or not supported by device.", default_profile);
58+ return -1;
59+ }
60 }
61
62 u->card = pa_card_new(u->core, &data);
63--
642.1.4
65