From 380a7fc2401ea26151e0383adff05314a263ac31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 25 Sep 2014 15:27:58 +0200 Subject: [PATCH] bluetooth: bluez4: Add profile name to sinks and sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now a2dp and hsp sinks and sources will have different names which means that applications and other modules can use sink/source to distinguish selected profile. Module module-device-restore uses sink/source name and port name as identifier, so if different profiles have different names module-device-restore can store volume settings for each profile. So with this patch it is possible to configure different volume settings for a2dp and hsp profiles. This patch does not change port names so gnome applications will be happy. Note that similar patch is needed also for bluez5, but I'm not using bluez5 so I cannot write or test it. Signed-off-by: Pali Rohár --- src/modules/bluetooth/module-bluez4-device.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c index c70e4a629..0be0c57af 100644 --- a/src/modules/bluetooth/module-bluez4-device.c +++ b/src/modules/bluetooth/module-bluez4-device.c @@ -1371,7 +1371,7 @@ static void source_set_volume_cb(pa_source *s) { } /* Run from main thread */ -static char *get_name(const char *type, pa_modargs *ma, const char *device_id, bool *namereg_fail) { +static char *get_name(const char *type, pa_modargs *ma, const char *device_id, const char *profile, bool *namereg_fail) { char *t; const char *n; @@ -1396,7 +1396,10 @@ static char *get_name(const char *type, pa_modargs *ma, const char *device_id, b *namereg_fail = false; } - return pa_sprintf_malloc("bluez_%s.%s", type, n); + if (profile) + return pa_sprintf_malloc("bluez_%s.%s.%s", type, n, profile); + else + return pa_sprintf_malloc("bluez_%s.%s", type, n); } static int sco_over_pcm_state_update(struct userdata *u, bool changed) { @@ -1567,7 +1570,7 @@ static int add_sink(struct userdata *u) { if (u->profile == PA_BLUEZ4_PROFILE_HSP) pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone"); data.card = u->card; - data.name = get_name("sink", u->modargs, u->address, &b); + data.name = get_name("sink", u->modargs, u->address, pa_bluez4_profile_to_string(u->profile), &b); data.namereg_fail = b; if (pa_modargs_get_proplist(u->modargs, "sink_properties", data.proplist, PA_UPDATE_REPLACE) < 0) { @@ -1638,7 +1641,7 @@ static int add_source(struct userdata *u) { pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone"); data.card = u->card; - data.name = get_name("source", u->modargs, u->address, &b); + data.name = get_name("source", u->modargs, u->address, pa_bluez4_profile_to_string(u->profile), &b); data.namereg_fail = b; if (pa_modargs_get_proplist(u->modargs, "source_properties", data.proplist, PA_UPDATE_REPLACE) < 0) { @@ -2267,7 +2270,7 @@ static int add_card(struct userdata *u) { pa_proplist_sets(data.proplist, "bluez.path", device->path); pa_proplist_setf(data.proplist, "bluez.class", "0x%06x", (unsigned) device->class); pa_proplist_sets(data.proplist, "bluez.alias", device->alias); - data.name = get_name("card", u->modargs, device->address, &b); + data.name = get_name("card", u->modargs, device->address, NULL, &b); data.namereg_fail = b; if (pa_modargs_get_proplist(u->modargs, "card_properties", data.proplist, PA_UPDATE_REPLACE) < 0) {