diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c index 979bb6de9..95287f19c 100644 --- a/src/modules/bluetooth/module-bluez5-device.c +++ b/src/modules/bluetooth/module-bluez5-device.c @@ -1000,6 +1000,8 @@ static int add_source(struct userdata *u) { data.name = pa_sprintf_malloc("bluez_source.%s.%s", u->device->address, pa_bluetooth_profile_to_string(u->profile)); data.namereg_fail = false; pa_proplist_sets(data.proplist, "bluetooth.protocol", pa_bluetooth_profile_to_string(u->profile)); + if (u->a2dp_codec) + pa_proplist_sets(data.proplist, PA_PROP_BLUETOOTH_CODEC, u->a2dp_codec->name); pa_source_new_data_set_sample_spec(&data, &u->decoder_sample_spec); if (u->profile == PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT) pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone"); @@ -1184,6 +1186,8 @@ static int add_sink(struct userdata *u) { data.name = pa_sprintf_malloc("bluez_sink.%s.%s", u->device->address, pa_bluetooth_profile_to_string(u->profile)); data.namereg_fail = false; pa_proplist_sets(data.proplist, "bluetooth.protocol", pa_bluetooth_profile_to_string(u->profile)); + if (u->a2dp_codec) + pa_proplist_sets(data.proplist, PA_PROP_BLUETOOTH_CODEC, u->a2dp_codec->name); pa_sink_new_data_set_sample_spec(&data, &u->encoder_sample_spec); if (u->profile == PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT) pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone"); @@ -1643,6 +1647,10 @@ static int start_thread(struct userdata *u) { u->source->set_volume(u->source); } + if (u->sink || u->source) + if (u->a2dp_codec) + pa_proplist_sets(u->card->proplist, PA_PROP_BLUETOOTH_CODEC, u->a2dp_codec->name); + return 0; } @@ -1650,6 +1658,9 @@ static int start_thread(struct userdata *u) { static void stop_thread(struct userdata *u) { pa_assert(u); + if (u->sink || u->source) + pa_proplist_unset(u->card->proplist, PA_PROP_BLUETOOTH_CODEC); + if (u->sink) pa_sink_unlink(u->sink); diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h index 5da01664b..9df10927d 100644 --- a/src/pulse/proplist.h +++ b/src/pulse/proplist.h @@ -270,6 +270,9 @@ PA_C_DECL_BEGIN /** For context: whether to forcefully disable data transfer via POSIX or memfd shared memory. This property overrides any other client configuration which would otherwise enable SHM communication channels. \since 15.0 */ #define PA_PROP_CONTEXT_FORCE_DISABLE_SHM "context.force.disable.shm" +/** For a bluez device: the currently selected codec name. \since 15.0 */ +#define PA_PROP_BLUETOOTH_CODEC "bluetooth.codec" + /** A property list object. Basically a dictionary with ASCII strings * as keys and arbitrary data as values. \since 0.9.11 */ typedef struct pa_proplist pa_proplist;